From: Peter Rabbitson Date: Fri, 1 Jul 2016 10:22:48 +0000 (+0200) Subject: Audit all local() calls within lib/ and t/lib X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7db939decd3929e2800c7ab5ec883cb859b68927;p=dbsrgits%2FDBIx-Class-Historic.git Audit all local() calls within lib/ and t/lib Correct some of them to fire less frequently (local is *expensive*) --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index c51c45d..725f30d 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -2371,7 +2371,7 @@ sub DESTROY { # however beware - on older perls the exception seems randomly untrappable # due to some weird race condition during thread joining :((( local $SIG{__DIE__} if $SIG{__DIE__}; - local $@; + local $@ if DBIx::Class::_ENV_::UNSTABLE_DOLLARAT; eval { weaken $_[0]->{schema}; diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index fff27dd..3bcc37f 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -1058,7 +1058,7 @@ sub throw_exception { my $guard = scope_guard { return if $guard_disarmed; - local $SIG{__WARN__}; + local $SIG{__WARN__} if $SIG{__WARN__}; Carp::cluck(" !!! DBIx::Class INTERNAL PANIC !!! @@ -1436,7 +1436,7 @@ sub DESTROY { # due to some weird race condition during thread joining :((( if (length ref $srcs->{$source_name} and refcount($srcs->{$source_name}) > 1) { local $SIG{__DIE__} if $SIG{__DIE__}; - local $@; + local $@ if DBIx::Class::_ENV_::UNSTABLE_DOLLARAT; eval { $srcs->{$source_name}->schema($self); weaken $srcs->{$source_name}; diff --git a/lib/DBIx/Class/Storage/BlockRunner.pm b/lib/DBIx/Class/Storage/BlockRunner.pm index 9b5bdbc..9d191c8 100644 --- a/lib/DBIx/Class/Storage/BlockRunner.pm +++ b/lib/DBIx/Class/Storage/BlockRunner.pm @@ -190,7 +190,8 @@ sub _run { ) or ! do { - local $self->storage->{_in_do_block_retry_handler} = 1; + local $self->storage->{_in_do_block_retry_handler} = 1 + unless $self->storage->{_in_do_block_retry_handler}; $self->retry_handler->($self) } ); diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 6c2940c..132c8d4 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1304,7 +1304,9 @@ sub _determine_driver { if ((not $self->_driver_determined) && (not $self->{_in_determine_driver})) { my $started_connected = 0; - local $self->{_in_determine_driver} = 1; + + local $self->{_in_determine_driver} = 1 + unless $self->{_in_determine_driver}; if (ref($self) eq __PACKAGE__) { my $driver; diff --git a/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm b/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm index 3677ec3..e5e36ab 100644 --- a/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm +++ b/lib/DBIx/Class/Storage/DBI/Firebird/Common.pm @@ -54,6 +54,8 @@ sub _dbh_get_autoinc_seq { $table_name = $self->sql_maker->quote_char ? $table_name : uc($table_name); local $dbh->{LongReadLen} = 100000; + + # FIXME - this is likely *WRONG* local $dbh->{LongTruncOk} = 1; my $sth = $dbh->prepare(<<'EOF'); diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 838c8da..61767ba 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -297,11 +297,12 @@ sub _dbh_execute { return shift->$next(@_) if $self->transaction_depth; - # cheat the blockrunner we are just about to create - # we do want to rerun things regardless of outer state - local $self->{_in_do_block}; + # Cheat the blockrunner we are just about to create: + # We *do* want to rerun things regardless of outer state + local $self->{_in_do_block} + if $self->{_in_do_block}; - return DBIx::Class::Storage::BlockRunner->new( + DBIx::Class::Storage::BlockRunner->new( storage => $self, wrap_txn => 0, retry_handler => sub { diff --git a/lib/DBIx/Class/Storage/DBIHacks.pm b/lib/DBIx/Class/Storage/DBIHacks.pm index 26cc4c8..c700d54 100644 --- a/lib/DBIx/Class/Storage/DBIHacks.pm +++ b/lib/DBIx/Class/Storage/DBIHacks.pm @@ -228,7 +228,8 @@ sub _adjust_select_args_for_complex_prefetch { my $inner_subq = do { # must use it here regardless of user requests (vastly gentler on optimizer) - local $self->{_use_join_optimizer} = 1; + local $self->{_use_join_optimizer} = 1 + unless $self->{_use_join_optimizer}; # throw away multijoins since we def. do not care about those inside the subquery # $inner_aliastypes *will* be redefined at this point diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index 2e265b5..b43d4bf 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -20,8 +20,8 @@ BEGIN { # prove) but I do not know it offhand, especially on older environments # Go with the safer option if ($INC{'Test/Builder.pm'}) { - local $| = 1; - print "#\n"; + select( ( select(\*STDOUT), $|=1 )[0] ); + print STDOUT "#\n"; } } diff --git a/t/lib/DBICTest/BaseSchema.pm b/t/lib/DBICTest/BaseSchema.pm index 726ce10..53036d3 100644 --- a/t/lib/DBICTest/BaseSchema.pm +++ b/t/lib/DBICTest/BaseSchema.pm @@ -262,7 +262,7 @@ sub connection { # we need to work with a forced fresh clone so that we do not upset any state # of the main $schema (some tests examine it quite closely) local $SIG{__WARN__} = sub {}; - local $SIG{__DIE__}; + local $SIG{__DIE__} if $SIG{__DIE__}; local $@; # this will either give us an undef $locktype or will determine things diff --git a/t/lib/DBICTest/Util.pm b/t/lib/DBICTest/Util.pm index 3e250cc..1529f90 100644 --- a/t/lib/DBICTest/Util.pm +++ b/t/lib/DBICTest/Util.pm @@ -104,8 +104,7 @@ sub await_flock ($$) { # prove -lj10 xt/extra/internals/ # select( ( select(\*STDOUT), $|=1 )[0] ); - - print "#\n"; + print STDOUT "#\n"; } } @@ -126,7 +125,7 @@ sub local_umask ($) { croak "Setting umask failed: $!" unless defined $old_umask; scope_guard(sub { - local ($@, $!, $?); + local ( $!, $^E, $?, $@ ); eval { defined(umask $old_umask) or die "nope";