Bug 38893 - Longoverdue cronjob gives error when run with "--library" flag and CircControl syspref set to "The library you are logged in at"
Summary: Longoverdue cronjob gives error when run with "--library" flag and CircContro...
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Andrew Fuerste-Henry
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 9596 38894
Blocks:
  Show dependency treegraph
 
Reported: 2025-01-14 19:17 UTC by Andrew Fuerste-Henry
Modified: 2025-01-31 09:55 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 38893: Quit job with message when longoverdue run with --library and CircControl set to logged in library (1.75 KB, patch)
2025-01-14 20:05 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 38893: Quit job with message when longoverdue run with --library and CircControl set to logged in library (1.81 KB, patch)
2025-01-22 09:28 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Fuerste-Henry 2025-01-14 19:17:50 UTC
Bug 9596 added the ability to limit longoverdue by library. The determination of which library to use for a given checkout is made based on the CircControl system preference. One of the options for CircControl is "The library you're logged in at."

If CircControl is set to "the library you're logged in at" and you run the longoverdue cron with the --library flag set, you get the error "Use of uninitialized value $lib in hash element at misc/cronjobs/longoverdue.pl line 484." because Koha doesn't know how to pick a branch -- no one is logged in.

Setting this to normal as it seems like mostly a "don't configure it like this" issue. But maybe we should give the cron something to follow if the syspref is logged-in-branch?
Comment 1 Andrew Fuerste-Henry 2025-01-14 20:05:41 UTC
Created attachment 176535 [details] [review]
Bug 38893: Quit job with message when longoverdue run with --library and CircControl set to logged in library

To test:
1: Set CircControl to "the item's library" and run longoverdue with the --library flag, it works
2: Set CircControl to "the library you are logged in at" and run longoverdue, it gives an error
3: Apply patch, restart all
4: run longoverdue, it quits and tells you "Use of --library flag not permitted when the CircControl system preference set to 'the library you are logged in at'"
Comment 2 Andrew Fuerste-Henry 2025-01-14 20:06:12 UTC
Possible there's a better solution here, but this is an improvement.
Comment 3 Jake Deery 2025-01-17 16:26:50 UTC
I'm afraid I'm gonna need a more descriptive test plan. When checked out on main, I get this when running the script:

kohadev-koha@kohadevbox:koha(main)$ ./misc/cronjobs/longoverdue.pl --confirm --library
Option library requires an argument

Weirdly, I get this if I flip the flags around:

kohadev-koha@kohadevbox:koha(main)$ ./misc/cronjobs/longoverdue.pl --library --confirm
### TEST MODE -- NO ACTIONS TAKEN ###
The library --confirm does not exist in the database

Worth noting, this happens with `CircControl` set any which way.

... the script does seem wonky, but I can't add my sign-off line without reproducing the issue. Sorry Andrew, could you provide more information for me?

Jake.
Comment 4 Martin Renvoize (ashimema) 2025-01-22 09:28:36 UTC
Created attachment 176889 [details] [review]
Bug 38893: Quit job with message when longoverdue run with --library and CircControl set to logged in library

To test:
1: Set CircControl to "the item's library" and run longoverdue with the --library flag, it works
2: Set CircControl to "the library you are logged in at" and run longoverdue, it gives an error
3: Apply patch, restart all
4: Run longoverdue, it quits and tells you "Use of --library flag not permitted when the CircControl system preference set to 'the library you are logged in at'"

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize (ashimema) 2025-01-22 09:30:13 UTC
I think this makes sense..  did wonder if we aught to just set $lib to the current library the loop is acting on.. i.e whatever was passed to the --library option of the script.. CircControl is a bit of a nonsense in this configuration here though I agree.
Comment 6 Marcel de Rooy 2025-01-31 09:55:12 UTC
Not sure why we just test this sofar in the script. Feels like we should test it much earlier and bail out.