From 4cb6b9062f27e558d4ab1ffda5b372a8c8180c11 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 7 Dec 2018 15:18:20 -0300 Subject: [PATCH] Bug 18936: Fix several issues --- Koha/CirculationRules.pm | 7 ++++--- Koha/Template/Plugin/CirculationRules.pm | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index d462a2137d..fdcd9d5506 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -240,14 +240,15 @@ sub get_effective_rules { sub set_rule { my ( $self, $params ) = @_; - for my $mandatory_parameter (qw( branchcode categorycode itemtype rule_name rule_value ) ) { + for my $mandatory_parameter (qw( rule_name rule_value ) ) { Koha::Exceptions::MissingParameter->throw( - "Required parameter 'branchcode' missing") + "Required parameter '$mandatory_parameter' missing") unless exists $params->{$mandatory_parameter}; } my $kind_info = $RULE_KINDS->{ $params->{rule_name} }; - croak "set_rule given unknown rule '$params->{rule_name}'!" + Koha::Exceptions::MissingParameter->throw( + "set_rule given unknown rule '$params->{rule_name}'!") unless defined $kind_info; # Enforce scope; a rule should be set for its defined scope, no more, no less. diff --git a/Koha/Template/Plugin/CirculationRules.pm b/Koha/Template/Plugin/CirculationRules.pm index 04587d4d51..2e40df9882 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{} or $branchcode eq q{*}; $itemtype = undef if $itemtype eq q{} or $branchcode eq q{*}; - my $rule = Koha::CirculationRules->get_effective_rule( + my $rule = Koha::CirculationRules->search( { branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype, rule_name => $rule_name, } - ); + )->next; return $rule->rule_value if $rule; } -- 2.11.0