From f8ffeded359beea69a1957f4e972c394177a1931 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@iki.fi>
Date: Mon, 22 Aug 2022 19:02:14 +0000
Subject: [PATCH] Bug 31112: (follow-up) Don't return "on_reserve" when there
 are 0 possible holds
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It's possible that there could be 0 possible reserves, for example
when the hold has already been filled, thus the check would fail as
the item count can never be less than 0.

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
---
 C4/Circulation.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 125c0c2744..1667ec7332 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -2963,7 +2963,7 @@ sub CanBookBeRenewed {
             notforloan   => 0,
             -not         => { itemnumber => $itemnumber } })->as_list;
 
-        return ( 0, "on_reserve" ) if scalar @other_items < scalar @possible_holds;
+        return ( 0, "on_reserve" ) if @possible_holds && (scalar @other_items < scalar @possible_holds);
 
         my %matched_items;
         foreach my $possible_hold (@possible_holds) {
-- 
2.30.2