[Bps-public-commit] dbix-searchbuilder branch, get-rid-of-prev-handle, created. 1.63_01-1-g32e891b

Ruslan Zakirov ruz at bestpractical.com
Fri Mar 29 05:07:18 EDT 2013


The branch, get-rid-of-prev-handle has been created
        at  32e891bbac4ce3af2784386a58fc16bc0b55fdcb (commit)

- Log -----------------------------------------------------------------
commit 32e891bbac4ce3af2784386a58fc16bc0b55fdcb
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Mar 29 12:36:16 2013 +0400

    drop $...::Handle::PrevHandle global
    
    The way this global variable is used is not documented
    and may result in bugs that are hard to find.
    
    For example, SearchBuilder or Record can go through Storable
    cycle and on de-serialization object gets handle without dbh,
    so it gets PrevHandle and may disconnect it during DESTROY.
    It can be very unexpected.

diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index 10c8e76..6bb29a6 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -11,7 +11,7 @@ use Encode qw();
 
 use DBIx::SearchBuilder::Util qw/ sorted_values /;
 
-use vars qw(@ISA %DBIHandle $PrevHandle $DEBUG %TRANSDEPTH %FIELDS_IN_TABLE);
+use vars qw(@ISA %DBIHandle $DEBUG %TRANSDEPTH %FIELDS_IN_TABLE);
 
 
 =head1 NAME
@@ -328,11 +328,11 @@ sub dbh {
   
   #If we are setting the database handle, set it.
   if ( @_ ) {
-      $DBIHandle{$self} = $PrevHandle = shift;
+      $DBIHandle{$self} = shift;
       %FIELDS_IN_TABLE = ();
   }
 
-  return($DBIHandle{$self} ||= $PrevHandle);
+  return $DBIHandle{$self};
 }
 
 
diff --git a/t/03transactions.t b/t/03transactions.t
index c0a486d..162f685 100644
--- a/t/03transactions.t
+++ b/t/03transactions.t
@@ -23,10 +23,6 @@ SKIP: {
 
 	my $handle = get_handle( $d );
     isa_ok($handle, 'DBIx::SearchBuilder::Handle');
-    { # clear PrevHandle
-        no warnings 'once';
-        $DBIx::SearchBuilder::Handle::PrevHandle = undef;
-    }
 
 diag("disconnected handle") if $ENV{'TEST_VERBOSE'};
     is($handle->TransactionDepth, undef, "undefined transaction depth");

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list