https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42334

--- Comment #4 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
Created attachment 208483
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=208483&action=edit
Bug 42334: Replace invalid useDaysMode and daysmode values

Koha::Library::Calendar::DateCalculator rejects invalid days_mode
values. Before, any unknown value (in the useDaysMode system preference
or the daysmode circulation rule) silently behaved like 'Days', and
neither the circulation rules editor nor the API validate them, so
existing installations could have such values stored.

This patch adds an atomic update that replaces invalid values with
'Days', which keeps the previous behavior, and warns about each one so
it can be reviewed. Empty daysmode rule values are left alone, as they
mean the system preference applies.

Test plan:
1. Set invalid values:
   $ ktd --shell
  k$ koha-mysql kohadev -e "UPDATE systempreferences SET value='noDays' WHERE
variable='useDaysMode'; INSERT INTO circulation_rules
(branchcode,rule_name,rule_value) VALUES
('CPL','daysmode','Calender'),('MPL','daysmode','Dayweek');"
2. Apply patch, run:
  k$ updatedatabase
=> SUCCESS: Warnings about useDaysMode ('noDays') and the CPL daysmode
rule ('Calender') are displayed
3. Check the values:
  k$ koha-mysql kohadev -e "SELECT value FROM systempreferences WHERE
variable='useDaysMode'; SELECT branchcode,rule_value FROM circulation_rules
WHERE rule_name='daysmode';"
=> SUCCESS: useDaysMode and the CPL rule are 'Days', the MPL rule is
still 'Dayweek'
4. Run updatedatabase again
=> SUCCESS: No warnings, nothing changes
5. Sign off :-D

Assisted-by: Opus 5.5 (Anthropic)

-- 
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/

Reply via email to