X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB.pm;h=79a251a0961976aff3fbfca161492d821639d1d8;hb=4af01ce416458581a85d5a836c147bd214eb03bd;hp=40c8a9596a06541fd37a30d55df6542545ab08cb;hpb=660c7e5312f7fae7766b731f7001e5e8197c6887;p=kivitendo-erp.git diff --git a/SL/DB.pm b/SL/DB.pm index 40c8a9596..79a251a09 100644 --- a/SL/DB.pm +++ b/SL/DB.pm @@ -7,6 +7,7 @@ use Data::Dumper; use English qw(-no_match_vars); use Rose::DB; use Rose::DBx::Cache::Anywhere; +use Scalar::Util qw(blessed); use base qw(Rose::DB); @@ -131,14 +132,14 @@ sub with_transaction { my $rv = 1; local $@; - + my $return_array = wantarray; eval { - wantarray + $return_array ? $self->do_transaction(sub { @result = $code->(@args) }) : $self->do_transaction(sub { $result = $code->(@args) }); } or do { my $error = $self->error; - if (ref $error) { + if (blessed $error) { if ($error->isa('SL::X::DBError')) { # gobble the exception } else { @@ -149,7 +150,7 @@ sub with_transaction { } }; - return wantarray ? @result : $result; + return $return_array ? @result : $result; } 1;