[Bug 44149] New: Packaged last-borrower anonymization cron omits --confirm and fails when disabled
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44149 Bug ID: 44149 Summary: Packaged last-borrower anonymization cron omits --confirm and fails when disabled Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Command-line Utilities Assignee: nugged@gmail.com Reporter: nugged@gmail.com QA Contact: testopia@bugs.koha-community.org CC: jake.deery@openfifth.co.uk, robin@catalyst.net.nz Depends on: 23260 Target Milestone: --- The packaged daily cron invokes anonymize_last_borrowers.pl without --confirm, although that option is required when AnonymizeLastBorrower is enabled. Consequently the scheduled invocation exits with an error instead of performing the configured anonymization. When AnonymizeLastBorrower is disabled, the script also prints an error and exits 1. A deliberately disabled feature should be a quiet, successful no-op. This behavior was reported on Bug 23260 comments 248-249 and Bug 43314 comments 7-9, but the current main still contains both problems. There is also a related false-success case: a non-empty AnonymousPatron that does not identify an existing patron makes the existing method return undef, but the script ignores that result and exits 0. Steps to reproduce on a disposable Koha test database: 1. Set AnonymizeLastBorrower to 0. 2. Run perl misc/cronjobs/anonymize_last_borrowers.pl, first without --confirm and then with --confirm. Record stdout, stderr and exit status. 3. Enable AnonymizeLastBorrower, configure a valid AnonymousPatron and AnonymizeLastBorrowerDays, and prepare an eligible old last-borrower row. 4. Run the script using the arguments from debian/koha-core.koha-common.cron.daily. That entry lacks --confirm. 5. Set AnonymousPatron to a non-existent patron number and run the script with --confirm. Expected result: Disabled runs are silent, exit 0 and leave data unchanged. The packaged command includes --confirm and anonymizes eligible rows when enabled and correctly configured. Invalid or missing AnonymousPatron and enabled runs without confirmation remain errors. Actual result: Disabled runs print an error and exit 1. The packaged enabled invocation fails for missing --confirm. A non-empty invalid AnonymousPatron instead silently exits 0 without performing the operation. Proposed fix: Add --confirm to the packaged daily entry, quietly succeed when the feature is disabled, and treat the anonymization method's undef result as an error. Preserve the existing retention period, item filters and confirmation requirement. A defined zero-row result remains successful. This is a follow-up to Bug 23260: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23260 Related discussion, without a runtime fix, is on Bug 43314: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43314 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23260 [Bug 23260] Anonymize (remove) patron data from items_last_borrower -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44149 Andrii Nugged <nugged@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=43314 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44149 --- Comment #1 from Andrii Nugged <nugged@gmail.com> --- Created attachment 211928 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211928&action=edit Bug 44149: Fix the packaged last borrower anonymization cron The packaged daily job invokes anonymize_last_borrowers.pl without --confirm, although the script requires that option. When AnonymizeLastBorrower is disabled, the script also reports an error instead of treating the configured no-op as a successful run. Pass --confirm in the packaged invocation and exit quietly with status 0 when the preference is disabled. Keep confirmation mandatory when enabled. Report an error when the existing anonymization method returns undef for an invalid AnonymousPatron, rather than reporting success. The existing retention period and damaged/lost/withdrawn filters remain unchanged. Enabling the preference now allows the packaged daily job to perform its intended anonymization; disabling it remains the opt-out. Follow-up to bug 23260; related disabled-cron discussion on bug 43314. Test plan (use a disposable Koha test database): Before applying the patch: 1. In the Koha shell, set AnonymizeLastBorrower to 0. Run perl misc/cronjobs/anonymize_last_borrowers.pl and repeat with --confirm. Both runs incorrectly print a preference error and exit 1 instead of silently succeeding. 2. Enable AnonymizeLastBorrower, set AnonymousPatron to an existing patron, and set AnonymizeLastBorrowerDays to 30. Prepare an ordinary last-borrower row older than 30 days, a recent row, and old rows for damaged, lost and withdrawn items. 3. Inspect debian/koha-core.koha-common.cron.daily: its anonymizer command lacks --confirm. Running the script with those arguments exits 1 and leaves the old eligible row unchanged. 4. Set AnonymousPatron to a non-existent patron number and run the script with --confirm. It incorrectly exits 0 without anonymizing anything. Apply the patch. After applying the patch: 1. Repeat step 1. Both runs are silent, exit 0, and leave data unchanged, including when AnonymousPatron is unset. 2. Restore the valid setup and fixtures from step 2. The packaged command now includes --confirm. Run the script with those arguments: it exits 0 and changes only the eligible old row to AnonymousPatron. Recent, damaged, lost and withdrawn controls remain unchanged. 3. Repeat the command: a successful run with no remaining eligible rows must still exit 0. Running without --confirm must still exit 1. 4. Repeat step 4: the script now reports the invalid AnonymousPatron and exits 1. An empty AnonymousPatron must also remain an error. Co-Authored-By: Loontik <loontik@nugged.team> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44149 Andrii Nugged <nugged@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org