lib/Cxn.pm: Silence a warning (in 5.14)

I think this warning actually happens everywhere, but because of
how it happens, it gets masked by older versions of Perl.

Basically, Cxn's DESTROY method checks if $self->{dbh}, and if true,
calls ->disconnect on that. However, during global destruction --
when DESTROY is called -- you have no assurances that DESTROY
will be called before the dbh was already reaped.

This commit makes sure that the $self->{dbh} we have inside DESTROY
is actually a reference.
This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-03-30 16:03:04 -03:00
parent 33954b72f9
commit b007016215

View File

@@ -193,7 +193,7 @@ sub name {
sub DESTROY {
my ($self) = @_;
if ( $self->{dbh} ) {
if ( $self->{dbh} && ref($self->{dbh}) ) {
PTDEBUG && _d('Disconnecting dbh', $self->{dbh}, $self->{name});
$self->{dbh}->disconnect();
}