From c00e26830fc627251da5950c375813223d4b95db Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 6 Aug 2025 15:20:29 +0000 Subject: [PATCH] Bug 39802: Report when no branches will be selected and exit This highlights the issue mentioned in the last patch, reporting that nothign will be done and exiting the script To test: 1 - perl misc/cronjobs/longoverdue.pl -l 5=1 --library CPL 2 - Confirm script exits with warning that nothing has been done --- misc/cronjobs/longoverdue.pl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index e41862306d7..c8c863dbb4d 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -106,6 +106,21 @@ if ( scalar @branches && scalar @skip_branches ) { ); } +my $lost_control_pref = C4::Context->preference('LostChargesControl'); +my $home_holding_pref = C4::Context->preference('HomeOrHoldingBranch'); +if ( ( scalar @branches || scalar @skip_branches ) + && $lost_control_pref eq 'PickupLibrary' + && !( C4::Context->userenv->{branch} ) ) +{ + pod2usage( + -verbose => 0, + -message => + "There is no branch set for the cron user, LostCharge Control is set to 'library you are logged in at'.\n" + . "No branches will satisfy this requirement - exiting.", + -exitval => 1 + ); +} + if ( scalar @$itemtype && scalar @$skip_itemtype ) { pod2usage( -verbose => 1, @@ -359,9 +374,7 @@ sub longoverdue_sth { return C4::Context->dbh->prepare($query); } -my $dbh = C4::Context->dbh; -my $lost_control_pref = C4::Context->preference('LostChargesControl'); -my $home_holding_pref = C4::Context->preference('HomeOrHoldingBranch'); +my $dbh = C4::Context->dbh; my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode'); $borrower_category = [ map { uc $_ } @$borrower_category ]; -- 2.39.5