From: Peter Rabbitson Date: Thu, 26 Feb 2015 16:47:29 +0000 (+0100) Subject: At last a safer Moo (lots of kludges undone) X-Git-Tag: v0.082820~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8ab476744ce42bc4a23da61186c8087d4d7fdc13;p=dbsrgits%2FDBIx-Class.git At last a safer Moo (lots of kludges undone) (cherry pick of 0020e364) --- diff --git a/Changes b/Changes index 9562a9c..b3ae1cb 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for DBIx::Class + * Misc + - Depend on newer Moo, to benefit from a safer runtime (RT#93004) + 0.082810 2014-10-25 13:58 (UTC) * Fixes - Fix incorrect collapsing-parser source being generated in the diff --git a/Makefile.PL b/Makefile.PL index b3ac93a..409ec2b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -56,7 +56,7 @@ my $runtime_requires = { 'Data::Page' => '2.00', 'Devel::GlobalDestruction' => '0.09', 'Hash::Merge' => '0.12', - 'Moo' => '1.006001', + 'Moo' => '2.000', 'MRO::Compat' => '0.12', 'Module::Find' => '0.07', 'namespace::clean' => '0.24', diff --git a/lib/DBIx/Class/Storage/BlockRunner.pm b/lib/DBIx/Class/Storage/BlockRunner.pm index d7fe5d2..be29701 100644 --- a/lib/DBIx/Class/Storage/BlockRunner.pm +++ b/lib/DBIx/Class/Storage/BlockRunner.pm @@ -10,27 +10,7 @@ use Context::Preserve 'preserve_context'; use DBIx::Class::_Util qw(is_exception qsub); use Scalar::Util qw(weaken blessed reftype); use Try::Tiny; - -# DO NOT edit away without talking to riba first, he will just put it back -# BEGIN pre-Moo2 import block -BEGIN { - my $initial_fatal_bits = (${^WARNING_BITS}||'') & $warnings::DeadBits{all}; - - local $ENV{PERL_STRICTURES_EXTRA} = 0; - # load all of these now, so that lazy-loading does not escape - # the current PERL_STRICTURES_EXTRA setting - require Sub::Quote; - require Sub::Defer; - require Moo; - require Moo::Object; - require Method::Generate::Accessor; - require Method::Generate::Constructor; - - Moo->import; - ${^WARNING_BITS} &= ( $initial_fatal_bits | ~ $warnings::DeadBits{all} ); -} -# END pre-Moo2 import block - +use Moo; use namespace::clean; =head1 NAME diff --git a/lib/DBIx/Class/Storage/Statistics.pm b/lib/DBIx/Class/Storage/Statistics.pm index 7b0193d..42137bf 100644 --- a/lib/DBIx/Class/Storage/Statistics.pm +++ b/lib/DBIx/Class/Storage/Statistics.pm @@ -5,27 +5,7 @@ use warnings; use DBIx::Class::_Util qw(sigwarn_silencer qsub); use IO::Handle (); - -# DO NOT edit away without talking to riba first, he will just put it back -# BEGIN pre-Moo2 import block -BEGIN { - my $initial_fatal_bits = (${^WARNING_BITS}||'') & $warnings::DeadBits{all}; - - local $ENV{PERL_STRICTURES_EXTRA} = 0; - # load all of these now, so that lazy-loading does not escape - # the current PERL_STRICTURES_EXTRA setting - require Sub::Quote; - require Sub::Defer; - require Moo; - require Moo::Object; - require Method::Generate::Accessor; - require Method::Generate::Constructor; - - Moo->import; - ${^WARNING_BITS} &= ( $initial_fatal_bits | ~ $warnings::DeadBits{all} ); -} -# END pre-Moo2 import block - +use Moo; extends 'DBIx::Class'; use namespace::clean; diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index be34bc6..c11ee22 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -58,23 +58,7 @@ use DBIx::Class::Carp '^DBIx::Class|^DBICTest'; use Carp 'croak'; use Scalar::Util qw(weaken blessed reftype); use List::Util qw(first); - -# DO NOT edit away without talking to riba first, he will just put it back -# BEGIN pre-Moo2 import block -BEGIN { - my $initial_fatal_bits = (${^WARNING_BITS}||'') & $warnings::DeadBits{all}; - - local $ENV{PERL_STRICTURES_EXTRA} = 0; - # load all of these now, so that lazy-loading does not escape - # the current PERL_STRICTURES_EXTRA setting - require Sub::Quote; - require Sub::Defer; - - Sub::Quote->import('quote_sub'); - ${^WARNING_BITS} &= ( $initial_fatal_bits | ~ $warnings::DeadBits{all} ); -} -sub qsub ($) { goto "e_sub } # no point depping on new Moo just for this -# END pre-Moo2 import block +use Sub::Quote qw(qsub quote_sub); use base 'Exporter'; our @EXPORT_OK = qw( diff --git a/t/53lean_startup.t b/t/53lean_startup.t index 525c46a..5e417d3 100644 --- a/t/53lean_startup.t +++ b/t/53lean_startup.t @@ -102,7 +102,6 @@ BEGIN { namespace::clean Try::Tiny Sub::Name - strictures Sub::Defer Sub::Quote @@ -170,12 +169,6 @@ BEGIN { assert_no_missing_expected_requires(); } -# make sure we never loaded any of the strictures XS bullshit -{ - ok( ! exists $INC{ Module::Runtime::module_notional_filename($_) }, "$_ load never attempted" ) - for qw(indirect multidimensional bareword::filehandles); -} - done_testing; sub register_lazy_loadable_requires { diff --git a/t/lib/DBICTest/Util/LeakTracer.pm b/t/lib/DBICTest/Util/LeakTracer.pm index 613fedf..4c90362 100644 --- a/t/lib/DBICTest/Util/LeakTracer.pm +++ b/t/lib/DBICTest/Util/LeakTracer.pm @@ -366,20 +366,23 @@ END { $tb->note("Auto checked $refs_traced references for leaks - none detected"); } -# Disable this until better times - SQLT and probably other things -# still load strictures. Let's just wait until Moo2.0 and go from there -=begin for tears # also while we are here and not in plain runmode: make sure we never # loaded any of the strictures XS bullshit (it's a leak in a sense) - unless (DBICTest::RunMode->is_plain) { + unless ( + $ENV{MOO_FATAL_WARNINGS} + or + # FIXME - SQLT loads strictures explicitly, /facedesk + # remove this INC check when 0fb58589 and 45287c815 are rectified + $INC{'SQL/Translator.pm'} + or + DBICTest::RunMode->is_plain + ) { for (qw(indirect multidimensional bareword::filehandles)) { exists $INC{ Module::Runtime::module_notional_filename($_) } and $tb->ok(0, "$_ load should not have been attempted!!!" ) } } -=cut - } }