@@ -, +, @@ --- Koha/Items.pm | 19 ++++++++++--------- t/db_dependent/Koha/Items/BatchUpdate.t | 24 ++++++++++++++---------- tools/batchMod.pl | 8 ++++---- 3 files changed, 28 insertions(+), 23 deletions(-) --- a/Koha/Items.pm +++ a/Koha/Items.pm @@ -295,15 +295,16 @@ sub batch_update { my $old = $old_values->{$attribute}; my $new = $new_values->{$attribute}; - if ( $attribute eq 'permanent_location' && $new eq '' ){ - # In the case where permanent_location is exposed we need - # to preserve the original value when none is passed - # the script will send a blank value to indicate that it was - # included in the form - $modified++; - $new_values->{permanent_location} = $old; - $item->make_column_dirty('permanent_location'); - } + if ( $attribute eq 'permanent_location' && $new eq '' ) { + + # In the case where permanent_location is exposed we need + # to preserve the original value when none is passed + # the script will send a blank value to indicate that it was + # included in the form + $modified++; + $new_values->{permanent_location} = $old; + $item->make_column_dirty('permanent_location'); + } $modified++ if ( defined $old xor defined $new ) || ( defined $old && defined $new && $new ne $old ); --- a/t/db_dependent/Koha/Items/BatchUpdate.t +++ a/t/db_dependent/Koha/Items/BatchUpdate.t @@ -164,23 +164,27 @@ subtest 'permanent_location' => sub { plan tests => 2; - $items->batch_update({ + $items->batch_update( + { new_values => { - 'permanent_location' => 'perm', - 'location' => 'loc' - } - }); + 'permanent_location' => 'perm', + 'location' => 'loc' + } + } + ); $items->reset; $item = $item->get_from_storage; is( $item->permanent_location, 'perm', 'Updated as expected when value passed'); - $items->batch_update({ + $items->batch_update( + { new_values => { - 'permanent_location' => '', - 'location' => 'new_loc' - } - }); + 'permanent_location' => '', + 'location' => 'new_loc' + } + } + ); $items->reset; $item = $item->get_from_storage; --- a/tools/batchMod.pl +++ a/tools/batchMod.pl @@ -156,10 +156,10 @@ if ( $op eq "action" ) { grep { $_ ne "" } uniq $input->multi_param($cgi_var_name); next unless @v || $attr eq 'permanent_location'; - # 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 + # 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; } --