X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FCursor.pm;h=155855979a5f3a74602076526df19876a8e0bc41;hb=82c5f9168e30bc9dc7b681058298bb342582c5ec;hp=4d15401a244136a0dece1ca9f8068c1e58d70271;hpb=1b658919f5ff67e9ac656daf6642a3bae8cec282;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Cursor.pm b/lib/DBIx/Class/Storage/DBI/Cursor.pm index 4d15401..1558559 100644 --- a/lib/DBIx/Class/Storage/DBI/Cursor.pm +++ b/lib/DBIx/Class/Storage/DBI/Cursor.pm @@ -5,9 +5,8 @@ use warnings; use base 'DBIx::Class::Cursor'; -use Try::Tiny; use Scalar::Util qw(refaddr weaken); -use List::Util 'shuffle'; +use DBIx::Class::_Util qw( detected_reinvoked_destructor dbic_internal_try ); use namespace::clean; __PACKAGE__->mk_group_accessors('simple' => @@ -73,7 +72,7 @@ Returns a new L object. return $self; } - sub CLONE { + sub DBIx::Class::__DBI_Cursor_iThreads_handler__::CLONE { for (keys %cursor_registry) { # once marked we no longer care about them, hence no # need to keep in the registry, left alone renumber the @@ -83,6 +82,11 @@ Returns a new L object. $self->{_intra_thread} = 1; } + + # Dummy NEXTSTATE ensuring the all temporaries on the stack are garbage + # collected before leaving this scope. Depending on the code above, this + # may very well be just a preventive measure guarding future modifications + undef; } } @@ -178,12 +182,14 @@ sub all { (undef, $sth) = $self->storage->_select( @{$self->{args}} ); - return ( + ( DBIx::Class::_ENV_::SHUFFLE_UNORDERED_RESULTSETS and ! $self->{attrs}{order_by} + and + require List::Util ) - ? shuffle @{$sth->fetchall_arrayref} + ? List::Util::shuffle( @{$sth->fetchall_arrayref} ) : @{$sth->fetchall_arrayref} ; } @@ -229,11 +235,23 @@ Resets the cursor to the beginning of the L. sub reset { $_[0]->__finish_sth if $_[0]->{sth}; $_[0]->sth(undef); + + # Dummy NEXTSTATE ensuring the all temporaries on the stack are garbage + # collected before leaving this scope. Depending on the code above, this + # may very well be just a preventive measure guarding future modifications + undef; } sub DESTROY { + return if &detected_reinvoked_destructor; + $_[0]->__finish_sth if $_[0]->{sth}; + + # Dummy NEXTSTATE ensuring the all temporaries on the stack are garbage + # collected before leaving this scope. Depending on the code above, this + # may very well be just a preventive measure guarding future modifications + undef; } sub __finish_sth { @@ -248,9 +266,36 @@ sub __finish_sth { my $self = shift; # No need to care about failures here - try { local $SIG{__WARN__} = sub {}; $self->{sth}->finish } if ( - $self->{sth} and ! try { ! $self->{sth}->FETCH('Active') } + dbic_internal_try { + local $SIG{__WARN__} = sub {}; + $self->{sth}->finish + } if ( + $self->{sth} + and + # weird double-negative to catch the case of ->FETCH throwing + # and attempt a finish *anyway* + ! dbic_internal_try { + ! $self->{sth}->FETCH('Active') + } ); + + # Dummy NEXTSTATE ensuring the all temporaries on the stack are garbage + # collected before leaving this scope. Depending on the code above, this + # may very well be just a preventive measure guarding future modifications + undef; } +=head1 FURTHER QUESTIONS? + +Check the list of L. + +=head1 COPYRIGHT AND LICENSE + +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L. + +=cut + 1;