From: Peter Rabbitson Date: Wed, 13 Jul 2016 15:06:30 +0000 (+0200) Subject: Fix inexplicable 5.8.x C3 errors - roll back e6efde04 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c356fcb1919c92e9f9b1dfe9fcc4c4cd33dc5ad6;p=dbsrgits%2FDBIx-Class.git Fix inexplicable 5.8.x C3 errors - roll back e6efde04 The optimization ends up breaking the entire C3 subsystem at a crucial time when add_columns has to see the correct register_column in order for IC::DT to populate the right column_info. Most importantly it seems that Class::C3::XS makes this optimization entirely moot (in fact minimal testing indicates things getting *faster* instead) --- diff --git a/Changes b/Changes index 1884dd0..72d7647 100644 --- a/Changes +++ b/Changes @@ -65,6 +65,8 @@ Revision history for DBIx::Class create()/populate() - Fix spurious warning on MSSQL cursor invalidation retries (RT#102166) - Fix several corner cases with Many2Many over custom relationships + - Fix corner cases of C3 composition being broken on OLD_MRO (5.8.x) + only: https://github.com/frioux/DBIx-Class-Helpers/issues/61 * Misc - Add explicit test for pathological example of asymmetric IC::DT setup diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 83d7e09..17a8bba 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -244,10 +244,6 @@ sub load_namespaces { my @to_register; { - no warnings qw/redefine/; - local *Class::C3::reinitialize = sub { } if DBIx::Class::_ENV_::OLD_MRO; - use warnings qw/redefine/; - # ensure classes are loaded and attached in inheritance order for my $result_class (values %$results_by_source_name) { $class->ensure_class_loaded($result_class); @@ -301,8 +297,6 @@ sub load_namespaces { .'with no corresponding Result class'; } - Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO; - $class->register_class(@$_) for (@to_register); return; @@ -384,10 +378,6 @@ sub load_classes { my @to_register; { - no warnings qw/redefine/; - local *Class::C3::reinitialize = sub { } if DBIx::Class::_ENV_::OLD_MRO; - use warnings qw/redefine/; - foreach my $prefix (keys %comps_for) { foreach my $comp (@{$comps_for{$prefix}||[]}) { my $comp_class = "${prefix}::${comp}"; @@ -404,7 +394,6 @@ sub load_classes { } } } - Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO; foreach my $to (@to_register) { $class->register_class(@$to); @@ -1041,10 +1030,6 @@ sub compose_namespace { #$schema->class_mappings({}); { - no warnings qw/redefine/; - local *Class::C3::reinitialize = sub { } if DBIx::Class::_ENV_::OLD_MRO; - use warnings qw/redefine/; - foreach my $source_name ($self->sources) { my $orig_source = $self->source($source_name); @@ -1064,7 +1049,8 @@ sub compose_namespace { for qw(class source resultset); } - Class::C3->reinitialize() if DBIx::Class::_ENV_::OLD_MRO; + # needed to cover the newly installed stuff via quote_sub above + Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO; # Give each composed class yet another *schema-less* source copy # this is used for the freeze/thaw cycle @@ -1752,6 +1738,9 @@ sub compose_connection { my $schema = $self->compose_namespace($target, 'DBIx::Class::ResultSetProxy'); quote_sub "${target}::schema", '$s', { '$s' => \$schema }; + # needed to cover the newly installed stuff via quote_sub above + Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO; + $schema->connection(@info); foreach my $source_name ($schema->sources) { my $source = $schema->source($source_name); diff --git a/t/lib/DBICTest/DeployComponent.pm b/t/lib/DBICTest/DeployComponent.pm index 590fc25..99fbbd7 100644 --- a/t/lib/DBICTest/DeployComponent.pm +++ b/t/lib/DBICTest/DeployComponent.pm @@ -1,9 +1,14 @@ # belongs to t/86sqlt.t package # hide from PAUSE DBICTest::DeployComponent; + use warnings; use strict; +# Part of a test, important to remain as-is +# see also DBICTest::Schema::Track +use base 'DBIx::Class::Core'; + our $hook_cb; sub sqlt_deploy_hook { diff --git a/t/lib/DBICTest/Schema/Track.pm b/t/lib/DBICTest/Schema/Track.pm index 10d49f7..ef3b14d 100644 --- a/t/lib/DBICTest/Schema/Track.pm +++ b/t/lib/DBICTest/Schema/Track.pm @@ -7,6 +7,8 @@ use strict; use base 'DBICTest::BaseResult'; use DBICTest::Util 'check_customcond_args'; +# The component order is Part of a test, +# important to remain as-is __PACKAGE__->load_components(qw{ +DBICTest::DeployComponent InflateColumn::DateTime