]> 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)
committerFridolin Somers <fridolin.somers@biblibre.com>
Wed, 25 Oct 2023 06:27:34 +0000 (20:27 -1000)
commit0f304c55e23ab382237846acb80ce94838f3e3f8
tree7cad19a0d5bd70a851f05fa7f3d3b92026777f76
parent458517fe0c3351c748dc50e2916ba4cc118620f1
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>
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