From: Dagfinn Ilmari Mannsåker Date: Tue, 21 Oct 2014 10:10:00 +0000 (+0100) Subject: Weaken $self to avoid leaks with nested closures on 5.8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cf52a9ad15a73aedfc1822643d63a9aa7982c72c;p=dbsrgits%2FDBIx-Class.git Weaken $self to avoid leaks with nested closures on 5.8 --- diff --git a/lib/DBIx/Class/Storage/DBI/Informix.pm b/lib/DBIx/Class/Storage/DBI/Informix.pm index 507ee51..b4a2ea8 100644 --- a/lib/DBIx/Class/Storage/DBI/Informix.pm +++ b/lib/DBIx/Class/Storage/DBI/Informix.pm @@ -6,6 +6,7 @@ use base qw/DBIx::Class::Storage::DBI/; use mro 'c3'; use Scope::Guard (); +use Scalar::Util 'weaken'; use Context::Preserve 'preserve_context'; use namespace::clean; @@ -66,6 +67,7 @@ sub with_deferred_fk_checks { $self->_do_query('SET CONSTRAINTS ALL DEFERRED'); + weaken($self); return preserve_context { my $sg = Scope::Guard->new(sub { $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE'); diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index 056b9cc..a67bc2f 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -6,6 +6,7 @@ use warnings; 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; @@ -30,6 +31,7 @@ sub with_deferred_fk_checks { $self->_do_query('SET CONSTRAINTS ALL DEFERRED'); + weaken($self); return preserve_context { my $sg = Scope::Guard->new(sub { $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');