From 98874bf9e2112db163a955eb1a13588276ee5bd7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 29 Sep 2016 13:35:57 +0100 Subject: [PATCH] Bug 17196: Fix - Update metadata on update Signed-off-by: Mason James Signed-off-by: Josef Moravec Signed-off-by: Zeno Tajoli Signed-off-by: Nick Clemens Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Biblio.pm | 1 + t/db_dependent/Biblio.t | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 3ff948bcf0..86cb512306 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3506,6 +3506,7 @@ sub ModBiblioMarc { # FIXME To replace with ->find_or_create? if ( my $m_rs = Koha::Biblio::Metadatas->find($metadata) ) { $m_rs->metadata( $record->as_xml_record($encoding) ); + $m_rs->store; } else { my $m_rs = Koha::Biblio::Metadata->new($metadata); $m_rs->metadata( $record->as_xml_record($encoding) ); diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index e6427f4e2b..48ed72f54e 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -108,8 +108,7 @@ sub run_tests { # Generate a record with just the ISBN my $marc_record = MARC::Record->new; - my $isbn_field = create_isbn_field( $isbn, $marcflavour ); - $marc_record->append_fields( $isbn_field ); + $marc_record->append_fields( create_isbn_field( $isbn, $marcflavour ) ); # Add the record to the DB my( $biblionumber, $biblioitemnumber ) = AddBiblio( $marc_record, '' ); @@ -119,6 +118,10 @@ sub run_tests { is( $data->{ title }, undef, '(GetBiblioData) Title field is empty in fresh biblio.'); + my ( $isbn_field, $isbn_subfield ) = get_isbn_field(); + my $marc = GetMarcBiblio( $biblionumber ); + is( $marc->subfield( $isbn_field, $isbn_subfield ), $isbn, ); + # Add title my $field = create_title_field( $title, $marcflavour ); $marc_record->append_fields( $field ); @@ -127,6 +130,9 @@ sub run_tests { is( $data->{ title }, $title, 'ModBiblio correctly added the title field, and GetBiblioData.'); is( $data->{ isbn }, $isbn, '(ModBiblio) ISBN is still there after ModBiblio.'); + $marc = GetMarcBiblio( $biblionumber ); + my ( $title_field, $title_subfield ) = get_title_field(); + is( $marc->subfield( $title_field, $title_subfield ), $title, ); my $itemdata = GetBiblioItemData( $biblioitemnumber ); is( $itemdata->{ title }, $title, @@ -320,19 +326,19 @@ sub create_issn_field { } subtest 'MARC21' => sub { - plan tests => 29; + plan tests => 31; run_tests('MARC21'); $dbh->rollback; }; subtest 'UNIMARC' => sub { - plan tests => 29; + plan tests => 31; run_tests('UNIMARC'); $dbh->rollback; }; subtest 'NORMARC' => sub { - plan tests => 29; + plan tests => 31; run_tests('NORMARC'); $dbh->rollback; }; -- 2.39.5