View | Details | Raw Unified | Return to bug 30779
Collapse All | Expand All

(-)a/C4/ImportBatch.pm (-10 lines)
Lines 1625-1640 sub _create_import_record { Link Here
1625
    return $import_record_id;
1625
    return $import_record_id;
1626
}
1626
}
1627
1627
1628
sub _update_import_record_marc {
1629
    my ($import_record_id, $marc_record, $marc_type) = @_;
1630
1631
    my $dbh = C4::Context->dbh;
1632
    my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ?
1633
                             WHERE  import_record_id = ?");
1634
    $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml($marc_type), $import_record_id);
1635
    $sth->finish();
1636
}
1637
1638
sub _add_auth_fields {
1628
sub _add_auth_fields {
1639
    my ($import_record_id, $marc_record) = @_;
1629
    my ($import_record_id, $marc_record) = @_;
1640
1630
(-)a/Koha/Import/Record.pm (-5 lines)
Lines 56-66 sub get_marc_record { Link Here
56
56
57
    my $record = MARC::Record->new_from_xml($self->marcxml, $self->encoding, $format);
57
    my $record = MARC::Record->new_from_xml($self->marcxml, $self->encoding, $format);
58
58
59
    if ($self->record_type eq 'biblio' && $args->{embed_items}) {
60
        require C4::ImportBatch;
61
        C4::ImportBatch::EmbedItemsInImportBiblio($record, $self->id);
62
    }
63
64
    return $record;
59
    return $record;
65
}
60
}
66
61
(-)a/catalogue/showmarc.pl (-1 / +1 lines)
Lines 62-68 if ($importid) { Link Here
62
            $format = 'UNIMARCAUTH';
62
            $format = 'UNIMARCAUTH';
63
        }
63
        }
64
64
65
        $record = $import_record->get_marc_record({ embed_items => 1 });
65
        $record = $import_record->get_marc_record();
66
    }
66
    }
67
}
67
}
68
else {
68
else {
(-)a/t/db_dependent/ImportBatch.t (-12 / +6 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Test::More tests => 19;
4
use Test::More tests => 18;
5
use utf8;
5
use utf8;
6
use File::Basename;
6
use File::Basename;
7
use File::Temp qw/tempfile/;
7
use File::Temp qw/tempfile/;
Lines 88-95 is_deeply( $importbatch1, $sample_import_batch1, Link Here
88
    "GetImportBatch returns the right informations about $sample_import_batch1" );
88
    "GetImportBatch returns the right informations about $sample_import_batch1" );
89
89
90
my $record = MARC::Record->new;
90
my $record = MARC::Record->new;
91
# FIXME Create another MARC::Record which won't be modified
92
# AddItemsToImportBiblio will remove the items field from the record passed in parameter.
93
my $original_record = MARC::Record->new;
91
my $original_record = MARC::Record->new;
94
$record->leader('03174nam a2200445 a 4500');
92
$record->leader('03174nam a2200445 a 4500');
95
$original_record->leader('03174nam a2200445 a 4500');
93
$original_record->leader('03174nam a2200445 a 4500');
Lines 162-176 my $import_record_id = AddBiblioToBatch( $id_import_batch1, 0, $record, 'utf8', Link Here
162
AddItemsToImportBiblio( $id_import_batch1, $import_record_id, $record, 0 );
160
AddItemsToImportBiblio( $id_import_batch1, $import_record_id, $record, 0 );
163
161
164
my $import_record = Koha::Import::Records->find($import_record_id);
162
my $import_record = Koha::Import::Records->find($import_record_id);
165
my $record_from_import_biblio_with_items = $import_record->get_marc_record({ embed_items => 1 });
163
my $record_from_import_biblio = $import_record->get_marc_record();
166
$original_record->leader($record_from_import_biblio_with_items->leader());
164
167
is_deeply( $record_from_import_biblio_with_items, $original_record, 'Koha::Import::Record::get_marc_record should return the record with items if specified' );
165
$original_record->leader($record_from_import_biblio->leader());
168
my $utf8_field = $record_from_import_biblio_with_items->subfield($item_tag, 'e');
166
is_deeply( $record_from_import_biblio, $original_record, 'Koha::Import::Record::get_marc_record should return the record in original state' );
167
my $utf8_field = $record_from_import_biblio->subfield($item_tag, 'e');
169
is($utf8_field, 'my edition ❤');
168
is($utf8_field, 'my edition ❤');
170
$original_record->delete_fields($original_record->field($item_tag)); #Remove items fields
171
my $record_from_import_biblio_without_items = $import_record->get_marc_record();
172
$original_record->leader($record_from_import_biblio_without_items->leader());
173
is_deeply( $record_from_import_biblio_without_items, $original_record, 'Koha::Import::Record::get_marc_record should return the record without items by default' );
174
169
175
my $another_biblio = $builder->build_sample_biblio;
170
my $another_biblio = $builder->build_sample_biblio;
176
C4::ImportBatch::SetMatchedBiblionumber( $import_record_id, $another_biblio->biblionumber );
171
C4::ImportBatch::SetMatchedBiblionumber( $import_record_id, $another_biblio->biblionumber );
177
- 

Return to bug 30779