From 76a3ff2a576f548412f6ae0cae12247529820a03 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 In all cases, we were embedding, so we don't need a way to get without Tests updated --- C4/ImportBatch.pm | 10 ---------- Koha/Import/Record.pm | 5 ----- catalogue/showmarc.pl | 2 +- t/db_dependent/ImportBatch.t | 17 ++++++----------- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 8af03b3de6..11637499bd 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -1625,16 +1625,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..e631bd3e85 100644 --- a/Koha/Import/Record.pm +++ b/Koha/Import/Record.pm @@ -56,11 +56,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 207710fded..74bb20d4cc 100755 --- a/catalogue/showmarc.pl +++ b/catalogue/showmarc.pl @@ -62,7 +62,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 0442d4d034..d8ff8ea95f 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 ); -- 2.30.2