Bugzilla – Attachment 146589 Details for
Bug 31187
Regression, Permanent shelving location is always updated when editing location VIA BATCH ITEM MOD if both are mapped to MARC fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31187: Preserve permanent_location if it is mapped to a field in the editor
Bug-31187-Preserve-permanentlocation-if-it-is-mapp.patch (text/plain), 3.85 KB, created by
Nick Clemens (kidclamp)
on 2023-02-13 16:41:36 UTC
(
hide
)
Description:
Bug 31187: Preserve permanent_location if it is mapped to a field in the editor
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-02-13 16:41:36 UTC
Size:
3.85 KB
patch
obsolete
>From baeec2af06e028ef243a9677a62b7ac9de095a51 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 13 Feb 2023 16:37:51 +0000 >Subject: [PATCH] Bug 31187: Preserve permanent_location if it is mapped to a > field in the editor > >To test: >1 - Map permanent_location to a marc field >2 - Expose that field in the item editor >3 - Cataloging -> Batch item modification >4 - Enter the barcode for an item >5 - Change the location of the item and retain the permanent location on saving >6 - note that permanent location is set to locatoin >7 - Apply patch >8 - Repeat >9 - Note permanent location is retained >--- > Koha/Items.pm | 9 +++++++ > t/db_dependent/Koha/Items/BatchUpdate.t | 34 ++++++++++++++++++++++++- > tools/batchMod.pl | 6 ++++- > 3 files changed, 47 insertions(+), 2 deletions(-) > >diff --git a/Koha/Items.pm b/Koha/Items.pm >index 5e9e808eee..3fe9271cd5 100644 >--- a/Koha/Items.pm >+++ b/Koha/Items.pm >@@ -288,6 +288,15 @@ 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'); >+ } > $modified++ > if ( defined $old xor defined $new ) > || ( defined $old && defined $new && $new ne $old ); >diff --git a/t/db_dependent/Koha/Items/BatchUpdate.t b/t/db_dependent/Koha/Items/BatchUpdate.t >index 2a3811e141..8af1c99d84 100755 >--- a/t/db_dependent/Koha/Items/BatchUpdate.t >+++ b/t/db_dependent/Koha/Items/BatchUpdate.t >@@ -16,7 +16,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests=> 7; >+use Test::More tests=> 8; > use utf8; > > use Koha::Database; >@@ -154,6 +154,38 @@ subtest 'blank' => sub { > > }; > >+subtest 'permanent_location' => sub { >+ >+ # This is a special case as some libraries add this field in the frameworks >+ # 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; >+ >+ $items->batch_update({ >+ new_values => { >+ '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({ >+ new_values => { >+ 'permanent_location' => '', >+ 'location' => 'new_loc' >+ } >+ }); >+ $items->reset; >+ >+ $item = $item->get_from_storage; >+ is( $item->permanent_location, 'perm', 'Permanent location not updated when mapped, so key present, but no value passed '); >+ >+}; >+ > subtest 'regex' => sub { > plan tests => 12; > >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index 31a61b7046..f25ff84635 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -153,7 +153,11 @@ if ( $op eq "action" ) { > my @v = > grep { $_ ne "" } uniq $input->multi_param($cgi_var_name); > >- next unless @v; >+ 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 > > $new_item_data->{$attr} = join '|', @v; > } >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31187
:
146589
|
150042
|
150046
|
150213
|
150278
|
150296
|
150597