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>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit b02b66acf5
)
This commit is contained in:
parent
c2169d1dfe
commit
54ddc31c71
5 changed files with 10 additions and 33 deletions
|
@ -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) = @_;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ if ($importid) {
|
|||
$format = 'UNIMARCAUTH';
|
||||
}
|
||||
|
||||
$record = $import_record->get_marc_record({ embed_items => 1 });
|
||||
$record = $import_record->get_marc_record();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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'};
|
||||
|
|
Loading…
Reference in a new issue