From: Dagfinn Ilmari Mannsåker Date: Mon, 20 Nov 2017 14:21:47 +0000 (+0000) Subject: Fix fix reference cycle in test col_accessor_map callback X-Git-Tag: 0.07048~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f3bed1f1082ac865772d577252a7c80af4504d4c;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Fix fix reference cycle in test col_accessor_map callback This was making the tester's DESTROY method try to reconnect to delete tables during global destruction, causing crashes (including segfaults). There's still something else causing causing occasional segfaults in XS_DBI_dispatch (called for DBI::common::DESTROY) during global destruction. In passing, use curry everywhere appropriate. --- diff --git a/Makefile.PL b/Makefile.PL index 9d79c14..095fb0b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -44,6 +44,7 @@ requires 'Class::Accessor::Grouped' => '0.10008'; requires 'Class::C3::Componentised' => '1.0008'; requires 'Class::Inspector' => '1.27'; requires 'Class::Unload' => '0.07'; +requires 'curry' => '1.000000', requires 'Data::Dump' => '1.06'; requires 'DBIx::Class' => '0.08127'; requires 'Hash::Merge' => '0.12'; diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index d100408..97050bc 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -11,6 +11,7 @@ use Sub::Util 'set_subname'; use DBIx::Class::Schema::Loader::Utils 'array_eq'; use Try::Tiny; use Hash::Merge 'merge'; +use curry; use namespace::clean; # Always remember to do all digits for the version even if they're 0 @@ -460,11 +461,11 @@ sub import { } elsif($opt eq 'naming') { no strict 'refs'; - *{"${cpkg}::naming"} = sub { $self->naming(@_) }; + *{"${cpkg}::naming"} = $self->curry::naming; } elsif($opt eq 'use_namespaces') { no strict 'refs'; - *{"${cpkg}::use_namespaces"} = sub { $self->use_namespaces(@_) }; + *{"${cpkg}::use_namespaces"} = $self->curry::use_namespaces, } } } diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 9103faf..dd38250 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -28,6 +28,7 @@ use DBIx::Class (); use Encode qw/encode decode/; use List::Util qw/all any none/; use File::Temp 'tempfile'; +use curry; use namespace::clean; our $VERSION = '0.07047'; @@ -2594,7 +2595,7 @@ sub _make_column_accessor_name { my $accessor = $self->_run_user_map( $self->col_accessor_map, - sub { $self->_default_column_accessor_name( shift ) }, + $self->curry::_default_column_accessor_name, $column_name, $column_context_info, ); @@ -2847,7 +2848,7 @@ sub _table2moniker { $self->_run_user_map( $self->moniker_map, - sub { $self->_default_table2moniker( shift ) }, + $self->curry::_default_table2moniker, $table ); } diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index ca41f74..bff0999 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -10,6 +10,7 @@ use Test::Differences; use DBIx::Class::Schema::Loader; use Class::Unload; use File::Path 'rmtree'; +use curry; use DBI; use File::Find 'find'; use Class::Unload (); @@ -259,7 +260,7 @@ sub setup_schema { col_collision_map => { '^(can)\z' => 'caught_collision_%s' }, rel_collision_map => { '^(set_primary_key)\z' => 'caught_rel_collision_%s' }, relationship_attrs => { many_to_many => { order_by => 'me.id' } }, - col_accessor_map => sub { $self->test_col_accessor_map(@_) }, + col_accessor_map => $self->curry::weak::test_col_accessor_map, result_components_map => { LoaderTest2X => 'TestComponentForMap', LoaderTest1 => '+TestComponentForMapFQN' }, uniq_to_primary => 1, %{ $self->{loader_options} || {} },