]> 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)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 17 Oct 2023 17:45:31 +0000 (14:45 -0300)
commit2b58f4d89ca2d71c8979e4d87759fc45d63795f4
tree9d1a76e2d60ff98bc77bf9e6c9c905d8fe81c577
parentebc7f492540821dc7f7b0339fb2f16c330ba67ef
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>
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