Bug 25556: fix for unnecessary empty name/value pairs creation
authorPetro Vashchuk <stalkernoid@gmail.com>
Mon, 25 May 2020 14:39:58 +0000 (17:39 +0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 26 May 2020 12:43:41 +0000 (14:43 +0200)
During the web-install onboarding process, when the default circulation rule gets created, "circulation_rules" table gets populated with empty rule_name/rule_value items. This behavior differs from how the "unset" button on the smart-rules.pl page in "Default checkout, hold and return policy" group acts and leads to unpredictable bug when empty "holdallowed" rule_name prevents holds from any user.
This fix removes creation of these empty name/value pairs.

To reproduce:
    1) Start with an empty installation (or delete all circulation rules and press "unset" in hold and return policy section on /cgi-bin/koha/admin/smart-rules.pl page). This is to have the circulation_rules table empty so onboarding.pl will work.
    2) Go through the onboarding.pl process and create a default circulation rule.
    3) Make sure that circulation_rules table contains will contain empty "patron_maxonsiteissueqty", "max_holds", "patron_maxissueqty", "returnbranch", "holdallowed" and "hold_fulfillment_policy" fields.
    4) Apply the patch.
    5) Repeat steps 1 and 2.
    6) Observe that there are none of six mentioned above name/value pairs appeared.

To reproduce the bug with empty "holdallowed" rule_name:
    1) Repeat steps 1, 2 and 3 that are listed in the previous instruction of reproduction, in order to get empty "holdallowed" field.
    2) Find existing or create a new book with available status and place a holding on it.
    3) Observe the yellow notification window with "Cannot place hold. No items are available to be placed on hold." warning.
    4) Apply the patch.
    5) Repeat steps 1 and 2.
    6) Observe that hold was successfully placed and yellow notification does not appear anymore.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

installer/onboarding.pl

index 547df29..5d10d23 100755 (executable)
@@ -286,30 +286,8 @@ if ( $step == 5 ) {
               }
         };
 
-        my $params_2 = {
-            branchcode   => $branchcode,
-            categorycode => $categorycode,
-            rules        => {
-                patron_maxissueqty       => "",
-                patron_maxonsiteissueqty => "",
-                max_holds                => "",
-            }
-        };
-
-        my $params_3 = {
-            branchcode => $branchcode,
-            itemtype   => $itemtype,
-            rules      => {
-                holdallowed             => "",
-                hold_fulfillment_policy => "",
-                returnbranch            => "",
-            }
-        };
-
         eval {
             Koha::CirculationRules->set_rules($params);
-            Koha::CirculationRules->set_rules($params_2);
-            Koha::CirculationRules->set_rules($params_3);
         };
 
         if ($@) {