From dc4f5debc277c1c7fdffa4bd78c9aea01020d0a3 Mon Sep 17 00:00:00 2001 From: Emily Lamancusa Date: Thu, 26 Oct 2023 10:21:09 -0400 Subject: [PATCH] Bug 34924: (QA follow-up) correctly handle digest data compilation for successful renewal automatic_renewals.pl does some data compilation for digest notices that depends on the error value returned from attempt_auto_renew. However, on successful renewal $error is undefined. Add additional checks on value of $success and definedness of $error to compile data accurately and avoid warns for undefined variable Signed-off-by: Emily Lamancusa --- misc/cronjobs/automatic_renewals.pl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index 72ed54fb31..8661d4f47b 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -213,16 +213,16 @@ while ( my $auto_renew = $auto_renews->next ) { if ( $wants_digest ) { # cache this one to process after we've run through all of the items. if ($digest_per_branch) { - $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; - $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon'; - $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{results}->{$error}++ ; + $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $success; + $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $success || $error eq 'auto_too_soon'; + $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{results}->{defined $error ? $error : 'auto-renew'}++ ; push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; - $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && $error ne 'auto_too_soon'; + $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && (!$error || $error ne 'auto_too_soon'); } else { - $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; - $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon'; - $renew_digest->{ $auto_renew->borrowernumber }->{results}->{$error}++ ; - $renew_digest->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && $error ne 'auto_too_soon'; + $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $success; + $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $success || $error eq 'auto_too_soon'; + $renew_digest->{ $auto_renew->borrowernumber }->{results}->{defined $error ? $error : 'auto-renew'}++ ; + $renew_digest->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && (!$error || $error ne 'auto_too_soon'); push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; } } -- 2.34.1