From da9bd7521996c464c6488e9914b76847ba51a49e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 24 Jul 2018 12:25:09 -0300 Subject: [PATCH] Bug 18887: Use get_effective_rule instead of search Signed-off-by: Lisette Scheer Signed-off-by: Jesse Maseto Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- Koha/CirculationRules.pm | 4 ++++ Koha/Template/Plugin/CirculationRules.pm | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 76dc63d8cf..d594c1d1e1 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -50,6 +50,10 @@ sub get_effective_rule { croak q{No rule name passed in!} unless $rule_name; + for my $v ( $branchcode, $categorycode, $itemtype ) { + $v = undef if $v and $v eq '*'; + } + my $search_params; $search_params->{rule_name} = $rule_name; diff --git a/Koha/Template/Plugin/CirculationRules.pm b/Koha/Template/Plugin/CirculationRules.pm index cc1e9127af..d6c79c8c00 100644 --- a/Koha/Template/Plugin/CirculationRules.pm +++ b/Koha/Template/Plugin/CirculationRules.pm @@ -30,14 +30,14 @@ sub Get { $categorycode = undef if $categorycode eq q{}; $itemtype = undef if $itemtype eq q{}; - my $rule = Koha::CirculationRules->search( + my $rule = Koha::CirculationRules->get_effective_rule( { branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype, rule_name => $rule_name, } - )->next(); + ); return $rule->rule_value if $rule; } -- 2.39.5