[Bug 43559] New: Convert misc/cronjobs/membership_expiry.pl to the Getopt::Long::Descriptive convention (see bug 43546)
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Bug ID: 43559 Summary: Convert misc/cronjobs/membership_expiry.pl to the Getopt::Long::Descriptive convention (see bug 43546) Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Command-line Utilities Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org CC: jake.deery@openfifth.co.uk, robin@catalyst.net.nz Target Milestone: --- Convert the plain Getopt::Long option parsing in misc/cronjobs/membership_expiry.pl to Koha::Script->describe_options, per the convention established by bug 43546. This script has a mutually-exclusive option pair, --active/--inactive, currently enforced with a hand-rolled pod2usage check after parsing. Depends on bug 43557 (declarative mutually-exclusive option support in Koha::Script->describe_options), so this pair can be declared rather than reimplemented as a post-parse check. Test plan: 1. misc/cronjobs/membership_expiry.pl --help Confirm the description and all options are documented. 2. Confirm supplying --active and --inactive together is still rejected as mutually exclusive, and each still works on its own. 3. koha-qa.pl passes for the changed file. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |43557 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43557 [Bug 43557] Add declarative mutually-exclusive option support to Koha::Script->describe_options -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 206176 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=206176&action=edit Bug 43559: Convert membership_expiry.pl to the Getopt::Long::Descriptive convention Convert the plain Getopt::Long option parsing to Koha::Script->describe_options, per the convention established by bug 43546. -c ("confirm") is declared required => 1: the script already refused to do anything without it (pod2usage + exit), which is exactly what the required constraint gives for free, so the hand-rolled check is gone. --active/--inactive are declared exclusive (bug 43557), and each gets a Params::Validate callback requiring a positive number of months, replacing the equivalent hand-rolled "defined but zero" check. --letter/--letter_renew's defaults move into the option spec, replacing the "if !$letter_expiry" post-parse assignment. The TrackLastPatronActivityTriggers syspref gate on --active/--inactive stays a post-parse check, same as the DB-existence checks audited on the sibling bugs: it's a business-state check, not a shape one, and Koha::Script->describe_options has no declarative home for it. One behavior note: previously, when multiple problems existed at once (e.g. TrackLastPatronActivityTriggers unset AND --active 0), the syspref message always won because of the if/elsif chain's ordering. Now the positive-months callback runs during option parsing, before the script body's syspref check, so that message can win instead when both are wrong simultaneously. Either way the script still exits non-zero with a clear message; only which message is shown when two things are wrong at once can change. Also found, not touched: -n ("no mail") is parsed but was already unused by the rest of the script before this conversion -- the "prints to standard out instead" behavior the POD describes isn't implemented, and -p/-n aren't actually enforced as mutually exclusive in code despite the POD claiming so. Both predate this bug; worth their own bug rather than silently changing behavior here. Test plan: 1. membership_expiry.pl --help / --man 2. membership_expiry.pl (no options) Rejected: mandatory parameter 'c' missing. 3. membership_expiry.pl -c --active 0 Rejected: needs a positive number of months. 4. membership_expiry.pl -c --active 3 --inactive 2 Rejected: mutually exclusive. 5. membership_expiry.pl -c --active 3 Rejected: needs TrackLastPatronActivityTriggers (same as before). 6. membership_expiry.pl -c -v Runs to completion (exits early on MembershipExpiryDaysNotice not being set in the test DB, same as before). 7. koha-qa.pl passes. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #206176|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #2 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208583 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208583&action=edit Bug 43559: Convert membership_expiry.pl to the Getopt::Long::Descriptive convention Convert the plain Getopt::Long option parsing to Koha::Script->describe_options, per the convention established by bug 43546. -c ("confirm") is declared required => 1: the script already refused to do anything without it (pod2usage + exit), which is exactly what the required constraint gives for free, so the hand-rolled check is gone. --active/--inactive are declared exclusive (bug 43557), and each gets a Params::Validate callback requiring a positive number of months, replacing the equivalent hand-rolled "defined but zero" check. --letter/--letter_renew's defaults move into the option spec, replacing the "if !$letter_expiry" post-parse assignment. The TrackLastPatronActivityTriggers syspref gate on --active/--inactive stays a post-parse check, same as the DB-existence checks audited on the sibling bugs: it's a business-state check, not a shape one, and Koha::Script->describe_options has no declarative home for it. One behavior note: previously, when multiple problems existed at once (e.g. TrackLastPatronActivityTriggers unset AND --active 0), the syspref message always won because of the if/elsif chain's ordering. Now the positive-months callback runs during option parsing, before the script body's syspref check, so that message can win instead when both are wrong simultaneously. Either way the script still exits non-zero with a clear message; only which message is shown when two things are wrong at once can change. Also found, not touched: -n ("no mail") is parsed but was already unused by the rest of the script before this conversion -- the "prints to standard out instead" behavior the POD describes isn't implemented, and -p/-n aren't actually enforced as mutually exclusive in code despite the POD claiming so. Both predate this bug; worth their own bug rather than silently changing behavior here. Test plan: 1. membership_expiry.pl --help / --man 2. membership_expiry.pl (no options) Rejected: mandatory parameter 'c' missing. 3. membership_expiry.pl -c --active 0 Rejected: needs a positive number of months. 4. membership_expiry.pl -c --active 3 --inactive 2 Rejected: mutually exclusive. 5. membership_expiry.pl -c --active 3 Rejected: needs TrackLastPatronActivityTriggers (same as before). 6. membership_expiry.pl -c -v Runs to completion (exits early on MembershipExpiryDaysNotice not being set in the test DB, same as before). 7. koha-qa.pl passes. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208583|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #3 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 208597 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208597&action=edit Bug 43559: Convert membership_expiry.pl to the Getopt::Long::Descriptive convention Convert the plain Getopt::Long option parsing to Koha::Script->describe_options, per the convention established by bug 43546. -c ("confirm") is declared required => 1: the script already refused to do anything without it (pod2usage + exit), which is exactly what the required constraint gives for free, so the hand-rolled check is gone. --active/--inactive are declared exclusive (bug 43557), and each gets a Params::Validate callback requiring a positive number of months, replacing the equivalent hand-rolled "defined but zero" check. --letter/--letter_renew's defaults move into the option spec, replacing the "if !$letter_expiry" post-parse assignment. The TrackLastPatronActivityTriggers syspref gate on --active/--inactive stays a post-parse check, same as the DB-existence checks audited on the sibling bugs: it's a business-state check, not a shape one, and Koha::Script->describe_options has no declarative home for it. One behavior note: previously, when multiple problems existed at once (e.g. TrackLastPatronActivityTriggers unset AND --active 0), the syspref message always won because of the if/elsif chain's ordering. Now the positive-months callback runs during option parsing, before the script body's syspref check, so that message can win instead when both are wrong simultaneously. Either way the script still exits non-zero with a clear message; only which message is shown when two things are wrong at once can change. Also found, not touched: -n ("no mail") is parsed but was already unused by the rest of the script before this conversion -- the "prints to standard out instead" behavior the POD describes isn't implemented, and -p/-n aren't actually enforced as mutually exclusive in code despite the POD claiming so. Both predate this bug; worth their own bug rather than silently changing behavior here. Test plan: 1. membership_expiry.pl --help / --man 2. membership_expiry.pl (no options) Rejected: mandatory parameter 'c' missing. 3. membership_expiry.pl -c --active 0 Rejected: needs a positive number of months. 4. membership_expiry.pl -c --active 3 --inactive 2 Rejected: mutually exclusive. 5. membership_expiry.pl -c --active 3 Rejected: needs TrackLastPatronActivityTriggers (same as before). 6. membership_expiry.pl -c -v Runs to completion (exits early on MembershipExpiryDaysNotice not being set in the test DB, same as before). 7. koha-qa.pl passes. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #4 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210795 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210795&action=edit Bug 43559: (QA follow-up) update manual to double dash format -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #208597|0 |1 is obsolete| | Attachment #210795|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #5 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210800 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210800&action=edit Bug 43559: Convert membership_expiry.pl to the Getopt::Long::Descriptive convention Convert the plain Getopt::Long option parsing to Koha::Script->describe_options, per the convention established by bug 43546. -c ("confirm") is declared required => 1: the script already refused to do anything without it (pod2usage + exit), which is exactly what the required constraint gives for free, so the hand-rolled check is gone. --active/--inactive are declared exclusive (bug 43557), and each gets a Params::Validate callback requiring a positive number of months, replacing the equivalent hand-rolled "defined but zero" check. --letter/--letter_renew's defaults move into the option spec, replacing the "if !$letter_expiry" post-parse assignment. The TrackLastPatronActivityTriggers syspref gate on --active/--inactive stays a post-parse check, same as the DB-existence checks audited on the sibling bugs: it's a business-state check, not a shape one, and Koha::Script->describe_options has no declarative home for it. One behavior note: previously, when multiple problems existed at once (e.g. TrackLastPatronActivityTriggers unset AND --active 0), the syspref message always won because of the if/elsif chain's ordering. Now the positive-months callback runs during option parsing, before the script body's syspref check, so that message can win instead when both are wrong simultaneously. Either way the script still exits non-zero with a clear message; only which message is shown when two things are wrong at once can change. Also found, not touched: -n ("no mail") is parsed but was already unused by the rest of the script before this conversion -- the "prints to standard out instead" behavior the POD describes isn't implemented, and -p/-n aren't actually enforced as mutually exclusive in code despite the POD claiming so. Both predate this bug; worth their own bug rather than silently changing behavior here. Test plan: 1. membership_expiry.pl --help / --man 2. membership_expiry.pl (no options) Rejected: mandatory parameter 'c' missing. 3. membership_expiry.pl -c --active 0 Rejected: needs a positive number of months. 4. membership_expiry.pl -c --active 3 --inactive 2 Rejected: mutually exclusive. 5. membership_expiry.pl -c --active 3 Rejected: needs TrackLastPatronActivityTriggers (same as before). 6. membership_expiry.pl -c -v Runs to completion (exits early on MembershipExpiryDaysNotice not being set in the test DB, same as before). 7. koha-qa.pl passes. Signed-off-by: Michelle Spinney <mspinney@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #6 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210801 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210801&action=edit Bug 43559: (QA follow-up) update manual to double dash format Signed-off-by: Michelle Spinney <mspinney@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #210800|0 |1 is obsolete| | Attachment #210801|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #7 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210802 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210802&action=edit Bug 43559: Convert membership_expiry.pl to the Getopt::Long::Descriptive convention Convert the plain Getopt::Long option parsing to Koha::Script->describe_options, per the convention established by bug 43546. -c ("confirm") is declared required => 1: the script already refused to do anything without it (pod2usage + exit), which is exactly what the required constraint gives for free, so the hand-rolled check is gone. --active/--inactive are declared exclusive (bug 43557), and each gets a Params::Validate callback requiring a positive number of months, replacing the equivalent hand-rolled "defined but zero" check. --letter/--letter_renew's defaults move into the option spec, replacing the "if !$letter_expiry" post-parse assignment. The TrackLastPatronActivityTriggers syspref gate on --active/--inactive stays a post-parse check, same as the DB-existence checks audited on the sibling bugs: it's a business-state check, not a shape one, and Koha::Script->describe_options has no declarative home for it. One behavior note: previously, when multiple problems existed at once (e.g. TrackLastPatronActivityTriggers unset AND --active 0), the syspref message always won because of the if/elsif chain's ordering. Now the positive-months callback runs during option parsing, before the script body's syspref check, so that message can win instead when both are wrong simultaneously. Either way the script still exits non-zero with a clear message; only which message is shown when two things are wrong at once can change. Also found, not touched: -n ("no mail") is parsed but was already unused by the rest of the script before this conversion -- the "prints to standard out instead" behavior the POD describes isn't implemented, and -p/-n aren't actually enforced as mutually exclusive in code despite the POD claiming so. Both predate this bug; worth their own bug rather than silently changing behavior here. Test plan: 1. membership_expiry.pl --help / --man 2. membership_expiry.pl (no options) Rejected: mandatory parameter 'c' missing. 3. membership_expiry.pl -c --active 0 Rejected: needs a positive number of months. 4. membership_expiry.pl -c --active 3 --inactive 2 Rejected: mutually exclusive. 5. membership_expiry.pl -c --active 3 Rejected: needs TrackLastPatronActivityTriggers (same as before). 6. membership_expiry.pl -c -v Runs to completion (exits early on MembershipExpiryDaysNotice not being set in the test DB, same as before). 7. koha-qa.pl passes. Signed-off-by: Michelle Spinney <mspinney@clamsnet.org> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #8 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 210803 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210803&action=edit Bug 43559: (QA follow-up) update manual to double dash format Signed-off-by: Michelle Spinney <mspinney@clamsnet.org> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to main Version(s)| |26.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 --- Comment #9 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Thanks everyone! Pushed to main for 26.11! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pedro.amorim@openfifth.co.u | |k --- Comment #10 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Hi all, Small behaviour change worth knowing about: before this patch, an empty --letter or --letter_renew (e.g. '--letter=') fell back to MEMBERSHIP_EXPIRY / MEMBERSHIP_RENEWED. Now the default only applies when the option is omitted entirely, so an empty value is used as the letter code and no notice is sent. Unlikely to bite anyone in practice, not a blocker, just noting it for the record and a potential follow-up if agreed. Test plan: 1) Set 'MembershipExpiryDaysNotice' to 14 at http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=MembershipExpiryDaysNotice 2) Edit any patron and set 'Expiry date' to 14 days from today: http://localhost:8081/cgi-bin/koha/members/members-home.pl 3) Before applying the patch, run: perl misc/cronjobs/membership_expiry.pl -c -v -p --letter= 4) Notice 'Enqueued notices for 1 patrons' 5) Apply the patch and repeat 3) 6) Notice 'Enqueued notices for 0 patrons' -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |The `membership_expiry.pl` release notes| |cronjob now parses its | |options with the shared | |`Koha::Script` option | |handling. `--active` and | |`--inactive` cannot be used | |together, and each must be | |given a positive number of | |months. | | | |**Configuration** | |- `-c` (confirm) is still | |required. Without it the | |script prints its usage and | |does nothing. | |- Single-dash option names | |such as `-branch` or | |`-letter_renew` are | |accepted with a deprecation | |warning. Use the | |double-dash form, for | |example `--letter_renew`. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43559 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to main |Needs documenting CC| |lucas@bywatersolutions.com --- Comment #11 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Enhancement, no 26.05.x backport. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org