@@ -, +, @@ passed --- t/db_dependent/Koha/Items/BatchUpdate.t | 13 ++++++++++++- tools/batchMod.pl | 9 +++++---- 2 files changed, 17 insertions(+), 5 deletions(-) --- a/t/db_dependent/Koha/Items/BatchUpdate.t +++ a/t/db_dependent/Koha/Items/BatchUpdate.t @@ -162,7 +162,7 @@ subtest 'permanent_location' => sub { # to allow explicitly setting a temporary location. # When mapped an empty value is submitted in the form with the key of permanent_location - plan tests => 2; + plan tests => 3; $items->batch_update( { @@ -188,6 +188,17 @@ subtest 'permanent_location' => sub { $item = $item->get_from_storage; is( $item->permanent_location, 'perm', 'Permanent location not updated when mapped, so key present, but no value passed '); + $items->batch_update( + { + new_values => { + 'location' => 'loc' + } + } + )->reset; + + $item = $item->get_from_storage; + is( $item->permanent_location, 'loc', 'Permanent location updated to location when not mapped and key not present'); + }; subtest 'regex' => sub { --- a/tools/batchMod.pl +++ a/tools/batchMod.pl @@ -152,16 +152,17 @@ if ( $op eq "action" ) { }; } else { - my @v = - grep { $_ ne "" } uniq $input->multi_param($cgi_var_name); + my @form_attr = $input->multi_param($cgi_var_name); + my @values = + grep { $_ ne "" } uniq @form_attr; - next unless @v || $attr eq 'permanent_location'; + next unless @values || ( $attr eq 'permanent_location' && @form_attr ); # If permanent_location is present in the form we need to pass it forward # to indicate that the user may modify this field directly and so # it needs to be marked as 'dirty' on any update. Otherwise the object always # sets location to the permanent_location as well - $new_item_data->{$attr} = join '|', @v; + $new_item_data->{$attr} = join '|', @values; } } } --