X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FTxnScopeGuard.pm;h=f961c4e4446b00796286a577a92e58a592bb908d;hb=12a184d0a0c1868708e43aaabefe08f9e7ac9ec4;hp=583639f6dbeeb7946d5be87bb6ead17e8897b126;hpb=84efb6d7f74f92330bf03e923a5386bbf5e7cf7e;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Storage/TxnScopeGuard.pm b/lib/DBIx/Class/Storage/TxnScopeGuard.pm index 583639f..f961c4e 100644 --- a/lib/DBIx/Class/Storage/TxnScopeGuard.pm +++ b/lib/DBIx/Class/Storage/TxnScopeGuard.pm @@ -26,11 +26,9 @@ sub new { # # Deliberately *NOT* using is_exception - if someone left a misbehaving # antipattern value in $@, it's not our business to whine about it - if( defined $@ and length $@ ) { - weaken( - $guard->{existing_exception_ref} = (length ref $@) ? $@ : \$@ - ); - } + weaken( + $guard->{existing_exception_ref} = (length ref $@) ? $@ : \$@ + ) if( defined $@ and length $@ ); $storage->txn_begin; @@ -82,7 +80,7 @@ sub DESTROY { return unless defined $_[0]->{dbh}; - carp 'A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back.' + carp 'A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back' unless defined $current_exception; @@ -105,6 +103,11 @@ sub DESTROY { $@ = $current_exception if DBIx::Class::_ENV_::UNSTABLE_DOLLARAT; + + # Dummy NEXTSTATE ensuring the all temporaries on the stack are garbage + # collected before leaving this scope. Depending on the code above, this + # may very well be just a preventive measure guarding future modifications + undef; } 1;