https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43549
--- Comment #2 from Martin Renvoize (ashimema) <[email protected]> --- Created attachment 206180 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206180&action=edit Bug 43549: Convert cleanup_database.pl to the Getopt::Long::Descriptive convention Converts cleanup_database.pl's GetOptions call to Koha::Script->describe_options (bug 43546). This is a larger, ~50-option script; none map cleanly onto a per-option required constraint, since the actual requirement is "at least one of roughly 50 purge-type flags", not any single mandatory option. That check remains manual post-parse validation, as does the mutually-exclusive --restrictions/--all-restrictions check and the --illrequests-days-requires---illrequests-status check -- none of these are expressible as per-option constraints. They now use $usage->die for output consistent with the rest of the convention, rather than the script's own hand-rolled usage() sub, which is removed along with its ~80-line duplicated option summary (describe_options generates the equivalent from each option's own description). The optional-numeric-with-bare-flag-means-zero pattern used throughout (e.g. 'import:i' bare vs. 'import:i 60') is unchanged -- it's a Getopt::Long behaviour that Getopt::Long::Descriptive passes straight through, verified against several options in this conversion. This script had no existing POD (its --help was a hand-rolled heredoc), so a minimal NAME section is added -- otherwise the new --man option (bug 43546) would have nothing to show and falls back to dumping the raw source. Test plan: 1. Run: misc/cronjobs/cleanup_database.pl --help Confirm it lists all ~50 documented options and usage examples, and exits 0. 2. Run: misc/cronjobs/cleanup_database.pl --man Confirm it prints a NAME section (not a raw source dump) and exits 0. 3. Run: misc/cronjobs/cleanup_database.pl With the PurgeListShareInvitesOlderThan system preference empty, confirm it fails with "You did not specify any cleanup work for the script to do." and the usage text, and exits non-zero. (With that preference set, as in the KTD sample data, the script legitimately has purge work to do by default -- this is existing behaviour, unrelated to this conversion.) 4. Run: misc/cronjobs/cleanup_database.pl --restrictions 10 --all-restrictions misc/cronjobs/cleanup_database.pl --illrequests-days 10 Confirm both still fail with their existing, specific error messages. 5. Run a selection of purge flags without --confirm, e.g.: misc/cronjobs/cleanup_database.pl --sessions --verbose misc/cronjobs/cleanup_database.pl --old-issues 99999 --verbose misc/cronjobs/cleanup_database.pl --fees 5 --verbose misc/cronjobs/cleanup_database.pl --jobs-days --jobs-type foo --jobs-type bar --verbose Confirm dry-run reporting (including default-day substitution for bare numeric flags, e.g. bare --jobs-days defaulting to 1 day) matches this script's behavior before this patch. 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 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/
