From 3400e136a22351905db04ce1dafeef7e2d68c5e5 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 2 Jun 2025 09:50:19 -0300 Subject: [PATCH] Bug 40034: Only check notforloan on itemtype if it exists This patch makes the code in `CheckReserves` survive the non-existence of the referenced item type in the `items` table for the passed item. To test: 1. Apply the regression tests 2. Run: $ ktd --shell k$ prove t/db_dependent/Reserves.t => FAIL: Tests explode like this: ``` Can't call method "notforloan" on an undefined value at /kohadevbox/koha/C4/Reserves.pm line 870. ``` 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: David Nind --- C4/Reserves.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index cadd4d413e..d9c4ab19bb 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -865,10 +865,11 @@ sub CheckReserves { my $dont_trap = C4::Context->preference('TrapHoldsOnOrder') ? $item->notforloan > 0 : $item->notforloan; if ( !$dont_trap ) { - my $item_type = $item->effective_itemtype; - if ($item_type) { - return if Koha::ItemTypes->find($item_type)->notforloan; - } + my $effective_item_type = $item->effective_itemtype; + + my $item_type = Koha::ItemTypes->find($effective_item_type); + return + if $item_type && $item_type->notforloan; } else { return; } -- 2.39.5