Bug 37552: Wrap auto renewal attempt in eval to ensure script does not die
When libraries have a lot of checkouts, or an AMH, checkins can happen while the cron is running. This patch simply adds an eval around the auto renewal attempt in case of early check in or other errors. You can verify cron completed by enabling cronjob log in system preferences and checking the action logs To test: 1 - Add 'sleep(10);' to automatic_renewals.pl 2 - Set circulation rules to enable automatic renewals 3 - Issue an item to a patron 4 - perl misc/cronjobs/automatic_renewals.pl -v 5 - Confirm item would not be renewed 6 - perl misc/cronjobs/automatic_renewals.pl -v -c 7 - Quickly check in the item 8 - The cronjob dies DBIx::Class::Row::update(): Can't update Koha::Schema::Result::Issue=HASH(0x586e1a674fb0): row not found at /kohadevbox/koha/Koha/Object.pm line 172 9 - Apply patch 10 - Checkout the item again 11 - perl misc/cronjobs/automatic_renewals.pl -v -c 12 - Quickly checkin the item 13 - You get a warning, but the cron completes Signed-off-by: CJ Lynce <cj.lynce@westlakelibrary.org> Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
5c41c1c657
commit
8ef9ac5445
1 changed files with 7 additions and 1 deletions
|
@ -213,7 +213,13 @@ sub _ProcessRenewals {
|
|||
$wants_digest = 0;
|
||||
}
|
||||
|
||||
my ( $success, $error, $updated ) = $auto_renew->attempt_auto_renew( { confirm => $confirm } );
|
||||
my ( $success, $error, $updated );
|
||||
eval { ( $success, $error, $updated ) = $auto_renew->attempt_auto_renew( { confirm => $confirm } ); };
|
||||
if ($@) {
|
||||
print "An error was encountered in processing auto renewal for issue id: " . $auto_renew->issue_id . "\n";
|
||||
print "$@ \n";
|
||||
next;
|
||||
}
|
||||
if ($success) {
|
||||
if ($verbose) {
|
||||
say sprintf "Issue id: %s for borrower: %s and item: %s %s be renewed.",
|
||||
|
|
Loading…
Reference in a new issue