From 9adac1f4d43fd1bc90f0adead3249693dce5d285 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 12 May 2023 15:47:02 -0300 Subject: [PATCH] Bug 32129: (QA follow-up) Avoid duplicate calculation This patch stores the output from ->check_recall() (a Koha::Recall object or undef) and reuses afterwards, on a ternaty operator. Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 62f176d0799a3cf6422eb404646cbb17678f4c2a) Signed-off-by: Matt Blenkinsop --- Koha/Item.pm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 5dc28c59d8..681da5877e 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1969,14 +1969,15 @@ sub can_be_waiting_recall { } # Check the circulation rule for each relevant itemtype for this item - my $rule = Koha::CirculationRules->get_effective_rules({ - branchcode => $branchcode, - categorycode => $self->check_recalls ? $self->check_recalls->patron->categorycode : undef, - itemtype => $self->effective_itemtype, - rules => [ - 'recalls_allowed', - ], - }); + my $most_relevant_recall = $self->check_recalls; + my $rule = Koha::CirculationRules->get_effective_rules( + { + branchcode => $branchcode, + categorycode => $most_relevant_recall ? $most_relevant_recall->patron->categorycode : undef, + itemtype => $self->effective_itemtype, + rules => [ 'recalls_allowed', ], + } + ); # check recalls allowed has been set and is not zero return 0 if ( !defined($rule->{recalls_allowed}) || $rule->{recalls_allowed} == 0 ); -- 2.39.5