Bugzilla – Attachment 139288 Details for
Bug 30779
Do not need to remove items from import biblios marc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30779: Remove _update_import_record_marc and update tests
Bug-30779-Remove-updateimportrecordmarc-and-update.patch (text/plain), 5.89 KB, created by
Jonathan Druart
on 2022-08-17 13:08:56 UTC
(
hide
)
Description:
Bug 30779: Remove _update_import_record_marc and update tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-08-17 13:08:56 UTC
Size:
5.89 KB
patch
obsolete
>From 0c23aaa3c5a6e57a372c947fa89d8b3661995d18 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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 <jonathan.druart@bugs.koha-community.org> >--- > 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 7e009a1a175..ee76020fba7 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 d22e871525a..49a7710e235 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 207710fded4..74bb20d4cc6 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 c1b166f83bc..0184a8f5c56 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 54b33ddad97..a4eb7eab086 100755 >--- a/tools/showdiffmarc.pl >+++ b/tools/showdiffmarc.pl >@@ -77,7 +77,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.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30779
:
135051
|
138475
|
139275
|
139285
|
139287
| 139288