From cdb8d6e48e1986f1a2cca768f653399d9117881c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 5 Feb 2024 13:36:21 +0000 Subject: [PATCH] Bug 35993: Apply new routine to ModBiblioMarc Content-Type: text/plain; charset=utf-8 Now both AddBiblio and ModBiblio will insert 005 if not present. Test plan: Run t/db_dependent/Biblio.t And via interface: Add a new biblio record via Acquisition. Without this patch it does not have a 005, now it does. Signed-off-by: Marcel de Rooy --- C4/Biblio.pm | 10 ++++------ t/db_dependent/Biblio.t | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 300cfa281b..776c20d993 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -113,6 +113,7 @@ use Koha::Plugins; use Koha::RecordProcessor; use Koha::SearchEngine; use Koha::SearchEngine::Indexer; +use Koha::SimpleMARC; use Koha::Libraries; use Koha::Util::MARC; @@ -433,7 +434,7 @@ sub ModBiblio { # update MARC subfield that stores biblioitems.cn_sort _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode ); - # update the MARC record (that now contains biblio and items) with the new record data + # Insert or update the MARC record (that now contains biblio and items) with the new record data ModBiblioMarc( $record, $biblionumber, { skip_record_index => $skip_record_index } ); # modify the other koha tables @@ -2831,12 +2832,9 @@ sub ModBiblioMarc { } } - #enhancement 5374: update transaction date (005) for marc21/unimarc + # Update transaction date (005) for marc21/unimarc if($encoding =~ /MARC21|UNIMARC/) { - my @a= (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++; - # YY MM DD HH MM SS (update year and month) - my $f005= $record->field('005'); - $f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005; + Koha::SimpleMARC::update_last_transaction_time( { record => $record } ); } if ( C4::Context->preference('StripWhitespaceChars') ) { diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 4f096f7fe1..f093f47610 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 20; +use Test::More tests => 21; use Test::MockModule; use Test::Warn; use List::MoreUtils qw( uniq ); @@ -1022,6 +1022,21 @@ subtest 'ModBiblio on invalid record' => sub { ); }; +subtest 'AddBiblio/ModBiblio calling ModBiblioMarc for field 005' => sub { + plan tests => 2; + + my $marc_record = MARC::Record->new; + my ($biblionumber) = C4::Biblio::AddBiblio( $marc_record, '' ); + my $biblio = Koha::Biblios->find($biblionumber); + + my $field = $biblio->metadata->record->field('005'); + ok( $field && $field->data, 'Record contains field 005 after AddBiblio' ); + $marc_record = MARC::Record->new; + C4::Biblio::ModBiblio( $marc_record, $biblionumber, '' ); + $field = $biblio->metadata->record->field('005'); + ok( $field && $field->data, 'Record contains field 005 after ModBiblio' ); +}; + # Cleanup Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); $schema->storage->txn_rollback; -- 2.30.2