From bb0a36f524b5d819be1ef299730e14d2c398c962 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 15 Dec 2022 10:09:38 +0000 Subject: [PATCH] Bug 32472: [21.11] Force scalar context on acqorder->items Content-Type: text/plain; charset=utf-8 This resolves a crash like The method Koha::Item->count is not covered by tests! on the template construction [% IF ( order.items.count ) %] in koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt. Test plan (21.11): Receive an order line under this condition: quantityreceived>0 with items attached to the order line. Note: Should be possible, comes from production logs. Look for list context on ->items called from acqorder. The result of git grep "\->items" is too wide but we could theoretically miss an occurence with git grep "order.*\->items". With order.* we do catch $new_order_object->items.. Signed-off-by: Marcel de Rooy --- Koha/Acquisition/Order.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm index b9059b0132..f03f873a3d 100644 --- a/Koha/Acquisition/Order.pm +++ b/Koha/Acquisition/Order.pm @@ -326,7 +326,7 @@ sub items { # There is no FK on items (may have been deleted) my $items_rs = $self->_result->aqorders_items; my @itemnumbers = $items_rs->get_column( 'itemnumber' )->all; - return Koha::Items->search({ itemnumber => \@itemnumbers }); + return scalar Koha::Items->search({ itemnumber => \@itemnumbers }); # forcing scalar context for 21.11 prevents crash } =head3 biblio -- 2.30.2