From 54ddc31c71292a1c46dc3994ccd89b22896e7d04 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 17 Aug 2022 11:56:37 +0000 Subject: [PATCH] Bug 30779: Remove _update_import_record_marc and update tests This patch removes the now unused: _update_import_record_marc Additionally, as items are already present in import biblio we no longer need to embed them, so that parameter is removed and the option removed from the sub and pod and everywhere it was used In all cases, we were embedding, so we don't need a way to get without Tests updated Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit b02b66acf5ddac1af00215fbcc1d842777b67c3b) --- C4/ImportBatch.pm | 10 ---------- Koha/Import/Record.pm | 12 ++---------- catalogue/showmarc.pl | 2 +- t/db_dependent/ImportBatch.t | 17 ++++++----------- tools/showdiffmarc.pl | 2 +- 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 23ceb504a1..e7aa2f676a 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -1606,16 +1606,6 @@ sub _create_import_record { return $import_record_id; } -sub _update_import_record_marc { - my ($import_record_id, $marc_record, $marc_type) = @_; - - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ? - WHERE import_record_id = ?"); - $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml($marc_type), $import_record_id); - $sth->finish(); -} - sub _add_auth_fields { my ($import_record_id, $marc_record) = @_; diff --git a/Koha/Import/Record.pm b/Koha/Import/Record.pm index d22e871525..49a7710e23 100644 --- a/Koha/Import/Record.pm +++ b/Koha/Import/Record.pm @@ -37,15 +37,12 @@ Koha::Import::Record - Koha Import Record Object class Returns a MARC::Record object - my $marc_record = $import_record->get_marc_record({ embed_items => $embed_items }) - -If $embed_items is true then items from import_items are embedded into the -MARC::Record returned + my $marc_record = $import_record->get_marc_record() =cut sub get_marc_record { - my ($self, $args) = @_; + my ($self) = @_; my $marcflavour = C4::Context->preference('marcflavour'); @@ -56,11 +53,6 @@ sub get_marc_record { my $record = MARC::Record->new_from_xml($self->marcxml, $self->encoding, $format); - if ($self->record_type eq 'biblio' && $args->{embed_items}) { - require C4::ImportBatch; - C4::ImportBatch::EmbedItemsInImportBiblio($record, $self->id); - } - return $record; } diff --git a/catalogue/showmarc.pl b/catalogue/showmarc.pl index 8a9f0e9bad..f4325df38b 100755 --- a/catalogue/showmarc.pl +++ b/catalogue/showmarc.pl @@ -61,7 +61,7 @@ if ($importid) { $format = 'UNIMARCAUTH'; } - $record = $import_record->get_marc_record({ embed_items => 1 }); + $record = $import_record->get_marc_record(); } } else { diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t index 39ad22067e..c93bc53019 100755 --- a/t/db_dependent/ImportBatch.t +++ b/t/db_dependent/ImportBatch.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use Modern::Perl; -use Test::More tests => 19; +use Test::More tests => 18; use utf8; use File::Basename; use File::Temp qw/tempfile/; @@ -88,8 +88,6 @@ is_deeply( $importbatch1, $sample_import_batch1, "GetImportBatch returns the right informations about $sample_import_batch1" ); my $record = MARC::Record->new; -# FIXME Create another MARC::Record which won't be modified -# AddItemsToImportBiblio will remove the items field from the record passed in parameter. my $original_record = MARC::Record->new; $record->leader('03174nam a2200445 a 4500'); $original_record->leader('03174nam a2200445 a 4500'); @@ -162,15 +160,12 @@ my $import_record_id = AddBiblioToBatch( $id_import_batch1, 0, $record, 'utf8', AddItemsToImportBiblio( $id_import_batch1, $import_record_id, $record, 0 ); my $import_record = Koha::Import::Records->find($import_record_id); -my $record_from_import_biblio_with_items = $import_record->get_marc_record({ embed_items => 1 }); -$original_record->leader($record_from_import_biblio_with_items->leader()); -is_deeply( $record_from_import_biblio_with_items, $original_record, 'Koha::Import::Record::get_marc_record should return the record with items if specified' ); -my $utf8_field = $record_from_import_biblio_with_items->subfield($item_tag, 'e'); +my $record_from_import_biblio = $import_record->get_marc_record(); + +$original_record->leader($record_from_import_biblio->leader()); +is_deeply( $record_from_import_biblio, $original_record, 'Koha::Import::Record::get_marc_record should return the record in original state' ); +my $utf8_field = $record_from_import_biblio->subfield($item_tag, 'e'); is($utf8_field, 'my edition ❤'); -$original_record->delete_fields($original_record->field($item_tag)); #Remove items fields -my $record_from_import_biblio_without_items = $import_record->get_marc_record(); -$original_record->leader($record_from_import_biblio_without_items->leader()); -is_deeply( $record_from_import_biblio_without_items, $original_record, 'Koha::Import::Record::get_marc_record should return the record without items by default' ); my $another_biblio = $builder->build_sample_biblio; C4::ImportBatch::SetMatchedBiblionumber( $import_record_id, $another_biblio->biblionumber ); diff --git a/tools/showdiffmarc.pl b/tools/showdiffmarc.pl index 4961369d2d..b7dbc68b81 100755 --- a/tools/showdiffmarc.pl +++ b/tools/showdiffmarc.pl @@ -81,7 +81,7 @@ if( $record ) { if( $importid ) { my $import_record = Koha::Import::Records->find($importid); - my $recordImportid = $import_record->get_marc_record({ embed_items => 1 }); + my $recordImportid = $import_record->get_marc_record(); $formatted2 = $recordImportid->as_formatted; my $biblio = GetImportBiblios($importid); $importTitle = $biblio->[0]->{'title'}; -- 2.39.5