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. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commitdb382ebaff) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit4aaf0b3077) Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
parent
dc2eccbeac
commit
60c61af04c
|
|
@ -308,7 +308,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(
|
||||
|
|
|
|||
|
|
@ -1120,11 +1120,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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue