Bugzilla – Attachment 120616 Details for
Bug 27837
Permanent location is reverted to location when location updated and permanent_location mapped to MARC field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27837: Check the MARC directly, not the transformed item
Bug-27837-Check-the-MARC-directly-not-the-transfor.patch (text/plain), 2.26 KB, created by
Kyle M Hall (khall)
on 2021-05-06 12:12:44 UTC
(
hide
)
Description:
Bug 27837: Check the MARC directly, not the transformed item
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-05-06 12:12:44 UTC
Size:
2.26 KB
patch
obsolete
>From afe843f74655618815b380951d13ea669111e347 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 6 May 2021 08:09:04 -0400 >Subject: [PATCH] Bug 27837: Check the MARC directly, not the transformed item > >If permanent location is mapped, it will exist in the MARC. >However, when we are transforming our item hash to MARC, >we are losing our permanent location mapping, at least in unit tests. > >By checking the original MARC for the permenent location, we remove the >risk of losing it the "empty" permenent location through the >transformation process. We only need to know that it existed in the >original item marc to know we need to update it in the database. >--- > C4/Items.pm | 3 ++- > t/db_dependent/Items.t | 2 +- > 2 files changed, 3 insertions(+), 2 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 3ba49a2477..729c6e0b48 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -304,7 +304,8 @@ sub ModItemFromMarc { > my $item_object = Koha::Items->find($itemnumber); > my $item = TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' ); > >- my $has_permanent_location = exists $item->{permanent_location}; >+ my ( $perm_loc_tag, $perm_loc_subfield ) = C4::Biblio::GetMarcFromKohaField( "items.permanent_location" ); >+ my $has_permanent_location = defined $item_marc->subfield( $perm_loc_tag, $perm_loc_subfield ); > > # Retrieving the values for the fields that are not linked > my @mapped_fields = Koha::MarcSubfieldStructures->search( >diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t >index 5d4c5f8fba..3c079c779c 100755 >--- a/t/db_dependent/Items.t >+++ b/t/db_dependent/Items.t >@@ -1117,11 +1117,11 @@ subtest 'ModItemFromMarc' => sub { > $item->permanent_location(""); > $item->location('E'); > $marc = C4::Items::Item2Marc( $item->unblessed, $item->biblionumber ); >+ $marc->field('952')->add_subfields( "C", "" ); > ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber ); > $item = $item->get_from_storage; > is( $item->location, 'E', 'next new location set as expected' ); > is( $item->permanent_location, undef, 'permanent location is not updated if previously set as blank string' ); >- > }; > > $schema->storage->txn_rollback; >-- >2.24.3 (Apple Git-128)
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 27837
:
117570
|
117572
|
117625
|
117626
|
117627
|
117628
|
117634
|
117728
|
117729
|
117730
|
117735
|
117738
|
120361
|
120362
|
120363
|
120364
|
120562
|
120563
|
120564
|
120565
|
120566
|
120616
|
120628
|
120629
|
120832
|
121044
|
121045
|
121046
|
121047
|
121048
|
121049
|
121050
|
121051
|
121052