https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17656 --- Comment #316 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 196030 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196030&action=edit Bug 17656: (QA follow-up) guard against NULL irregularity columns and missing enddate Three defensive fixes in Koha::Subscription: 1. irregularities() and permanent_irregularities(): split(';', undef) produces a warning under 'use warnings' and returns ('') — a list containing one empty string — when the column is NULL (which is the case for all existing subscriptions after the DB migration adds permanent_irregularity). The resulting empty-string hash key in guess_irregularities could cause spurious false matches. Fixed by returning an empty list early when the column is NULL/empty. 2. guess_irregularities(): called Delta_Days(..., split(/-/, $enddate)) without checking whether $enddate is defined first. Open-ended subscriptions (weeklength/monthlength without a computed enddate, or any subscription where enddate is NULL) would cause Date::Calc to die with a fatal exception. Fixed by returning an empty list early when enddate is not set. Test plan: --- Test A: no warnings on subscriptions with NULL permanent_irregularity --- 1. Apply all patches and run the DB update (perl updatedatabase.pl inside KTD) 2. Open any existing subscription that was created before this patch series (it will have permanent_irregularity = NULL) 3. Edit the subscription and view the prediction pattern - No Perl warnings should appear in the Koha/Plack error log - The prediction pattern should display correctly 4. Renew the subscription - No warnings or errors in the log - Renewal completes normally with irregularity set to '' (empty) --- Test B: no crash on open-ended subscriptions --- 5. Create a subscription using 'Number of weeks' or 'Number of months' as the length type (not 'Number of issues'), so that enddate may be NULL or unpopulated before the first renewal 6. Set permanent irregularities and save 7. Renew the subscription - Should complete without a 500 error or Date::Calc exception - irregularity is saved as empty (no end date = cannot compute which issue numbers fall on irregular days) --- Test C: normal operation is unaffected --- 8. Create a daily subscription (1 issue/day, 7 issues) with Wednesday and Thursday marked as permanent irregularities 9. Renew the subscription - Verify irregularity is correctly populated for the new period - Verify Wednesday and Thursday are still checked in the edit form -- You are receiving this mail because: You are watching all bug changes.