I can't see a way $self could be the only strong reference to the
object: either $_[0] or some other copy would have to be strong in order
to have something to call the method on in the first place. However,
let's not have everyone reading or editing the code have to do that
reasoning.
use mro 'c3';
use Scope::Guard ();
-use Scalar::Util 'weaken';
use Context::Preserve 'preserve_context';
use namespace::clean;
$self->_do_query('SET CONSTRAINTS ALL DEFERRED');
- weaken($self);
return preserve_context {
+ my $inner_self = $self; # avoid nested closure leak on 5.8
my $sg = Scope::Guard->new(sub {
- $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
+ $inner_self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
});
$sub->()
} after => sub { $txn_scope_guard->commit };
use base qw/DBIx::Class::Storage::DBI/;
use Scope::Guard ();
-use Scalar::Util 'weaken';
use Context::Preserve 'preserve_context';
use DBIx::Class::Carp;
use Try::Tiny;
$self->_do_query('SET CONSTRAINTS ALL DEFERRED');
- weaken($self);
return preserve_context {
+ my $inner_self = $self; # avoid nested closure leak on 5.8
my $sg = Scope::Guard->new(sub {
- $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
+ $inner_self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
});
$sub->()
} after => sub { $txn_scope_guard->commit };