[Bast-commits] r5016 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/Storage t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Tue Oct 28 12:32:53 GMT 2008
Author: ribasushi
Date: 2008-10-28 12:32:52 +0000 (Tue, 28 Oct 2008)
New Revision: 5016
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/trunk/t/34exception_action.t
Log:
Fix an obscure bug in the DBI exception handler, clobbering the exception contents when the same $dbh is used outside of dbic code
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2008-10-28 11:11:20 UTC (rev 5015)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2008-10-28 12:32:52 UTC (rev 5016)
@@ -882,7 +882,12 @@
my $weak_self = $self;
weaken($weak_self);
$dbh->{HandleError} = sub {
- $weak_self->throw_exception("DBI Exception: $_[0]")
+ if ($weak_self) {
+ $weak_self->throw_exception("DBI Exception: $_[0]");
+ }
+ else {
+ croak ("DBI Exception: $_[0]");
+ }
};
$dbh->{ShowErrorStatement} = 1;
$dbh->{RaiseError} = 1;
Modified: DBIx-Class/0.08/trunk/t/34exception_action.t
===================================================================
--- DBIx-Class/0.08/trunk/t/34exception_action.t 2008-10-28 11:11:20 UTC (rev 5015)
+++ DBIx-Class/0.08/trunk/t/34exception_action.t 2008-10-28 12:32:52 UTC (rev 5016)
@@ -5,7 +5,7 @@
use lib qw(t/lib);
use DBICTest;
-plan tests => 8;
+plan tests => 9;
# Set up the "usual" sqlite for DBICTest
my $schema = DBICTest->init_schema;
@@ -68,3 +68,15 @@
# While we're at it, lets throw a custom exception through Storage::DBI
eval { $schema->storage->throw_exception('floob') };
like($@, qr/DBICTest::Exception is handling this: floob/);
+
+
+# This usage is a bit unusual but it was actually seen in the wild
+eval {
+
+ my $dbh = $schema->storage->dbh;
+ undef $schema;
+
+ $dbh->do ('glaring_syntax_error;');
+};
+like($@, qr/DBI Exception.+do failed/, 'Exception thrown even after $storage is destroyed');
+
More information about the Bast-commits
mailing list