From 543f3697a0d404f3fce6e3194e00e1f03ffb8a52 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Wed, 11 Oct 2017 11:37:46 +0200 Subject: [PATCH] use base before namespace::clean namespace::clean uses the hints hash to track when it should do its work. Without extra protection, using hints across nested module loads can crash on perl <= 5.8.3. Older versions of base.pm used a string eval, which served to provide the isolation needed to avoid the bug. Moving the use base before the use namespace::clean means the hints aren't used until after the other modules are loaded, which avoids this issue. An alternate workaround would involve localizing the hints, but this involves intercepting the module loads. This would mean using something like Module::Runtime or Lexical::SealRequireHints, although those modules don't currently provide the localization needed to workaround this specific issue. --- lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm | 3 ++- lib/DBIx/Class/Storage/DBI/Sybase.pm | 3 ++- lib/DBIx/Class/Storage/DBI/Sybase/MSSQL.pm | 3 ++- lib/SQL/Translator/Parser/DBIx/Class.pm | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm index de17f97ed..fde162d0a 100644 --- a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm +++ b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm @@ -5,10 +5,11 @@ use strict; use warnings; use Scalar::Util qw/weaken/; -use namespace::clean; use base 'DBIx::Class'; +use namespace::clean; + __PACKAGE__->mk_classdata('purge_object_index_every' => 1000); __PACKAGE__->mk_classdata('live_object_index' => { }); __PACKAGE__->mk_classdata('live_object_init_count' => { }); diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index a71426813..d8c95b4a6 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -3,10 +3,11 @@ package DBIx::Class::Storage::DBI::Sybase; use strict; use warnings; use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch ); -use namespace::clean; use base qw/DBIx::Class::Storage::DBI/; +use namespace::clean; + =head1 NAME DBIx::Class::Storage::DBI::Sybase - Base class for drivers using diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/Sybase/MSSQL.pm index 2cdad77e7..5c13b2ab9 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/MSSQL.pm @@ -4,7 +4,6 @@ use strict; use warnings; use DBIx::Class::Carp; -use namespace::clean; carp 'Setting of storage_type is redundant as connections through DBD::Sybase' .' are now properly recognized and reblessed into the appropriate subclass' @@ -18,6 +17,8 @@ carp 'Setting of storage_type is redundant as connections through DBD::Sybase' use base qw/DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server/; use mro 'c3'; +use namespace::clean; + 1; =head1 NAME diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index 14812ac93..fbe405cf5 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -18,10 +18,11 @@ use DBIx::Class::Carp qw/^SQL::Translator|^DBIx::Class|^Try::Tiny/; use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch bag_eq ); use Class::C3::Componentised; use Scalar::Util 'blessed'; -use namespace::clean; use base qw(Exporter); +use namespace::clean; + @EXPORT_OK = qw(parse); # -------------------------------------------------------------------