From 5891f70fb8dac9e43f3501a9255347b3e42d5ad1 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Thu, 15 Nov 2018 10:39:45 +0100 Subject: [PATCH] Bug 21842: test Koha::ItemType in defined in order recieve items table Like Bug 19194 calls on $itemtype->value must test the object is defined. This patch catalogue/getitem-ajax.pl Test plan : 1) Define system preference item-level_itypes on "specific item" 2) Define in framework a subfield of items field : mapped on items.itype and not mandatory 3) Create an item without value on this subfield 4) Go to Acquisitions -> Find a vendor or make a new one -> create a new basket 5) Add the record from Step 1 to your basket 6) Close the basket 7) Go back to the vendor and click "Receive shipments" 8) Put in an invoice number, click Next 9) Click the "Receive" link for your item 10) Click on "Edit" in items table 11) You see item editor in a new tab 12) Change something and save 13) Without patch your change is not update The ajax call is with HTTP 500 error containing : Can't call method "description" on an undefined value 14) With patch items table is updated --- catalogue/getitem-ajax.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/catalogue/getitem-ajax.pl b/catalogue/getitem-ajax.pl index 10df69ef75..5423ef1cad 100755 --- a/catalogue/getitem-ajax.pl +++ b/catalogue/getitem-ajax.pl @@ -73,7 +73,9 @@ if($itemnumber) { $item->{materials} = $descriptions->{lib} // ''; my $itemtype = Koha::ItemTypes->find( $item->{itype} ); - $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description? + if (defined $itemtype) { + $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description? + } } my $json_text = to_json( $item, { utf8 => 1 } ); -- 2.17.1