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

(-)a/misc/migration_tools/bulkmarcimport.pl (-3 / +5 lines)
Lines 564-570 RECORD: while () { Link Here
564
                # Create biblio, unless we already have it (either match or ISBN)
564
                # Create biblio, unless we already have it (either match or ISBN)
565
                my @import_warnings;
565
                my @import_warnings;
566
                $mod_biblio_options->{warnings} = \@import_warnings;
566
                $mod_biblio_options->{warnings} = \@import_warnings;
567
                $add_biblio_options->{warnings}  = \@import_warnings;
567
                $add_biblio_options->{warnings} = \@import_warnings;
568
                if ($matched_record_id) {
568
                if ($matched_record_id) {
569
                    eval { $biblioitemnumber = Koha::Biblios->find($matched_record_id)->biblioitem->biblioitemnumber; };
569
                    eval { $biblioitemnumber = Koha::Biblios->find($matched_record_id)->biblioitem->biblioitemnumber; };
570
                    if ($update) {
570
                    if ($update) {
Lines 626-633 RECORD: while () { Link Here
626
                    next RECORD;
626
                    next RECORD;
627
                }
627
                }
628
                for my $w ( grep { $_->{type} eq 'nonxml_stripped' } @import_warnings ) {
628
                for my $w ( grep { $_->{type} eq 'nonxml_stripped' } @import_warnings ) {
629
                    warn sprintf( "WARNING: Non-XML characters stripped from biblio %s: %s\n",
629
                    warn sprintf(
630
                        $record_id // $originalid, $w->{message} );
630
                        "WARNING: Non-XML characters stripped from biblio %s: %s\n",
631
                        $record_id // $originalid, $w->{message}
632
                    );
631
                    printlog(
633
                    printlog(
632
                        {
634
                        {
633
                            id     => $record_id // $originalid,
635
                            id     => $record_id // $originalid,
(-)a/t/db_dependent/Biblio.t (-13 / +19 lines)
Lines 1204-1232 subtest 'GetFrameworkCode' => sub { Link Here
1204
1204
1205
};
1205
};
1206
1206
1207
subtest 'ModBiblio on invalid record' => sub {
1207
subtest 'ModBiblio on record with strippable non-XML characters' => sub {
1208
    plan tests => 3;
1208
    plan tests => 3;
1209
1209
1210
    t::lib::Mocks::mock_preference( "CataloguingLog", 1 );
1210
    t::lib::Mocks::mock_preference( "CataloguingLog", 1 );
1211
1211
1212
    # We create a record with an onvalid control character in the MARC
1212
    # We create a record with an invalid control character (chr(31)) in the MARC
1213
    my $record = MARC::Record->new();
1213
    my $record = MARC::Record->new();
1214
    my $field  = MARC::Field->new( '650', '', '', 'a' => '00aD000015937' );
1214
    my $field  = MARC::Field->new( '650', '', '', 'a' => '00' . chr(31) . 'aD000015937' );
1215
    $record->append_fields($field);
1215
    $record->append_fields($field);
1216
1216
1217
    my ($biblionumber) = C4::Biblio::AddBiblio( $record, '' );
1217
    my ($biblionumber) = C4::Biblio::AddBiblio( $record, '' );
1218
1218
1219
    warning_like { C4::Biblio::ModBiblio( $record, $biblionumber, '' ); }
1219
    # New behaviour: strippable non-XML characters are silently fixed; the
1220
    qr/parser error : PCDATA invalid Char value 31/,
1220
    # stripping event is reported via the warnings arrayref, not Perl warn()
1221
        'Modding the biblio warns about the encoding issues';
1221
    my @warnings;
1222
    my $action_logs =
1222
    C4::Biblio::ModBiblio( $record, $biblionumber, '', { warnings => \@warnings } );
1223
        Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } );
1223
    like(
1224
    is( $action_logs->count, 1, "Modification of biblio was successful and recorded" );
1224
        $warnings[0]{message}, qr/parser error : PCDATA invalid Char value 31/,
1225
    my $action_log = $action_logs->next;
1225
        'Non-XML character stripping reported via warnings arrayref'
1226
    );
1227
1228
    my $metadata = Koha::Biblios->find($biblionumber)->metadata;
1226
    like(
1229
    like(
1227
        $action_log->info, qr/parser error : PCDATA invalid Char value 31/,
1230
        $metadata->nonxml_stripped, qr/parser error : PCDATA invalid Char value 31/,
1228
        "Metadata issue successfully logged in action logs"
1231
        'nonxml_stripped persisted on biblio_metadata after ModBiblio'
1229
    );
1232
    );
1233
1234
    my $action_logs =
1235
        Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } );
1236
    is( $action_logs->count, 1, "Modification of biblio was successfully recorded in action logs" );
1230
};
1237
};
1231
1238
1232
subtest 'UpdateTotalIssues on Invalid record' => sub {
1239
subtest 'UpdateTotalIssues on Invalid record' => sub {
1233
- 

Return to bug 35104