https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43550
--- Comment #1 from Martin Renvoize (ashimema) <[email protected]> --- Created attachment 206087 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206087&action=edit Bug 43550: Convert update_patrons_category.pl to the Getopt::Long::Descriptive convention Converts update_patrons_category.pl's GetOptions call to Koha::Script->describe_options (bug 43546), declaring --from/-f and --to/-t as required. Both were already effectively mandatory: the script dies with "Categories not found" if either fails to resolve to a real category, including when the option was never supplied at all. But the existing guard against that, if ( not $fromcat && $tocat ) { print "Must supply category from and to (-f & -t) ...\n"; pod2usage(1); } is itself buggy -- operator precedence makes it parse as "(not $fromcat) && $tocat", so it only catches the single case of --to given without --from. Missing both, or --from given without --to, both fell through this check entirely and ran the full --regbefore/--regafter date-range validation before hitting the "Categories not found" die. Declaring both options required replaces this ad hoc (and broken) check with declarative enforcement that correctly rejects all three missing-option combinations immediately, before any other validation runs -- the "Categories not found" die itself is unchanged and still guards against present-but-invalid category codes. The now-unused $remove_guarantors variable (declared but never wired to an option or referenced anywhere) is also dropped. Test plan: 1. Run: misc/cronjobs/update_patrons_category.pl --help Confirm it lists all documented options and usage examples, and exits 0. 2. Run: misc/cronjobs/update_patrons_category.pl --man Confirm it prints the script's full existing POD and exits 0. 3. Run each of: misc/cronjobs/update_patrons_category.pl misc/cronjobs/update_patrons_category.pl --from PT misc/cronjobs/update_patrons_category.pl --to L Confirm each fails immediately with a clear "Mandatory parameter ... missing" error and the usage text, before any other processing, and exits non-zero. 4. Run: misc/cronjobs/update_patrons_category.pl --from NOPE1 --to NOPE2 Confirm it still fails with "Categories not found" (unchanged behavior for present-but-invalid codes). 5. Run: misc/cronjobs/update_patrons_category.pl --from PT --to L --verbose Confirm it reports (without updating) which patrons would move from PT to L, matching this script's behavior before this patch. Add --confirm to actually perform the update. 6. Confirm koha-qa.pl passes for the changed file. Co-Authored-By: Claude Sonnet 5 <[email protected]> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes. _______________________________________________ Koha-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected] website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
