Bug 21079: (follow-up) Move from Try::Tiny to eval
In line with similar examples already in Koha, we now eval the transaction, instead of putting it in a try/catch block. This patch also addressed the other comments made in https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21079#c10 - AutoCommit & RaiseError are now reset - Don't set the version if the update fails Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
fccbdf4dae
commit
0372a9e95e
|
|
@ -1,4 +1,3 @@
|
|||
use Try::Tiny;
|
||||
$DBversion = 'XXX'; # will be replaced by the RM
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
|
||||
|
|
@ -58,9 +57,10 @@ if( CheckVersion( $DBversion ) ) {
|
|||
my $changed_str = join(',', @changed);
|
||||
|
||||
if (scalar @changed > 0) {
|
||||
my ($raise_error) = $dbh->{RaiseError};
|
||||
$dbh->{AutoCommit} = 0;
|
||||
$dbh->{RaiseError} = 1;
|
||||
try {
|
||||
eval {
|
||||
my $del = $dbh->do(
|
||||
"DELETE FROM illrequestattributes ".
|
||||
"WHERE illrequest_id IN ($changed_str)"
|
||||
|
|
@ -82,12 +82,18 @@ if( CheckVersion( $DBversion ) ) {
|
|||
}
|
||||
}
|
||||
$dbh->commit;
|
||||
} catch {
|
||||
warn "Upgrade to $DBversion failed: $_";
|
||||
eval { $dbh->rollback };
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
warn "Upgrade to $DBversion failed: $@\n";
|
||||
eval { $dbh->rollback };
|
||||
} else {
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug 21079 - Unify metadata schema across backends)\n";
|
||||
}
|
||||
|
||||
$dbh->{AutoCommit} = 1;
|
||||
$dbh->{RaiseError} = $raise_error;
|
||||
}
|
||||
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug 21079 - Unify metadata schema across backends)\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue