From ac67a91e022756b73df6f11d37764586ca0555e9 Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Thu, 27 Nov 2025 13:42:41 +0000 Subject: [PATCH] Bug 8137: (follow-up) Correction of the rule return if no priority rule is defined --- Koha/CirculationRules.pm | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 3308d27070..7b702f05ff 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -230,6 +230,7 @@ our $RULE_KINDS = { has_priority => { scope => [ 'branchcode', 'categorycode' ], }, + # Not included (deprecated?): # * accountsent # * reservecharge @@ -299,19 +300,16 @@ sub get_effective_rule { $search_params, { order_by => $order_by, - rows => 1, + rows => 1, } )->single; if ( grep { $_ eq $rule_name } ( 'maxissueqty', 'maxonsiteissueqty' ) ) { if ( defined $priority_rule ) { - if ( $priority_rule->rule_value > $rule->rule_value ) { - return $rule; - } - return $priority_rule; + return ( $priority_rule->rule_value > $rule->rule_value ) ? $rule : $priority_rule; } - } - else { + return $rule; + } else { return defined $priority_rule ? $priority_rule : $rule; } } @@ -344,8 +342,8 @@ sub get_effective_rule_value { my $has_priority = $params->{has_priority}; my $memory_cache = Koha::Cache::Memory::Lite->get_instance; - my $cache_key = sprintf "CircRules:%s:%s:%s:%s:%s", $rule_name // q{}, - $categorycode // q{}, $branchcode // q{}, $itemtype // q{} ,$has_priority // q{}; + my $cache_key = sprintf "CircRules:%s:%s:%s:%s:%s", $rule_name // q{}, + $categorycode // q{}, $branchcode // q{}, $itemtype // q{}, $has_priority // q{}; my $cached = $memory_cache->get_from_cache($cache_key); return $cached if $cached; -- 2.39.5