]> git.koha-community.org Git - koha.git/commit
Bug 27249: Prevent infinite loop when searching for an open day
authorJulian Maurice <julian.maurice@biblibre.com>
Tue, 18 Jul 2023 08:26:03 +0000 (10:26 +0200)
committerMatt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Mon, 13 Nov 2023 13:45:36 +0000 (13:45 +0000)
commit19c0d6c49290caccaeaaea8b0a51712b9a87de1b
tree975128477e854464e57787f982a7b30bc556e149
parentc721788c20db5d4eb2834404335d0454ce2b66f3
Bug 27249: Prevent infinite loop when searching for an open day

Calendars can be configured in a way that all days are closed.
The simplest way to do that is to configure a repeatable holiday for
every day of the week.
With such calendars, searching for an open day will literally take
forever.

This patch sets a hard limit on how many iterations are allowed before
giving up. This limit is set to the arbitrary value of 5000, which
should be large enough to be able to consider there is no open days if
we haven't found any with that many iterations, and small enough to
allow the loop to end quickly

Test plan:
1. Set system preference 'useDaysMode' to 'Use the calendar to push the
   due date to the next open day' ('Datedue'). Make sure the existing
   circulation rules do not conflict with that setting.
2. Browse to Tools ยป Calendar
3. Set every day of the week to "Holiday repeated every same day of the
   week"
4. Issue an item to a patron
5. Check the box and select 'Renew selected items'
6. The renewal should fail pretty quickly

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 2b58f4d89ca2d71c8979e4d87759fc45d63795f4)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 0f304c55e23ab382237846acb80ce94838f3e3f8)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Koha/Calendar.pm
Koha/Exceptions/Calendar.pm [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/js/checkouts.js
svc/renew
t/db_dependent/Holidays.t