From c7625330cbd417cd044e2fb31f90ccf1dc1f03ee Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Tue, 26 Jul 2022 13:18:43 +0300 Subject: [PATCH] Bug 31154: Pass biblionumber to Koha::UI::Form::Builder::Item->new from batchMod.pl to prevent error 500 When one tries to batch mod items and has "Use default values" checkbox checked on and their default framework contains default values, Koha dies on error 500. In logs it reads: Can't call method "field" on an undefined value at .../Koha/Koha/UI/Form/Builder/Item.pm line 164. This happens because in batchMod.pl line 269 we don't pass biblionumber as parameter to Koha::UI::Form::Builder::Item->new and thus Koha fails to fetch biblios marc record. To test: 1. Update default framework 952 and add a default value * Example: Add REF as default for 952$8 with standard sample data 2. Find some item(s) to modify 3. Provide barcodes of those item(s) and check checkbox "Use default values" 4. Hit "Continue" => error 500 is raised 5. Apply patch. 6. Repeat steps 3. and 4. Sponsored-by: Koha-Suomi Oy --- tools/batchMod.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/batchMod.pl b/tools/batchMod.pl index e24db19104..9c9ba58a50 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -266,7 +266,9 @@ if ($op eq "show"){ # Getting list of subfields to keep when restricted batchmod edit is enabled my @subfields_to_allow = $restrictededition ? split ' ', C4::Context->preference('SubfieldsToAllowForRestrictedBatchmod') : (); - my $subfields = Koha::UI::Form::Builder::Item->new->edit_form( + $biblionumber = Koha::Items->find($itemnumbers[0])->unblessed->{biblionumber}; + my $subfields = Koha::UI::Form::Builder::Item->new( + { biblionumber => $biblionumber } )->edit_form( { restricted_editition => $restrictededition, ( -- 2.25.1