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

(-)a/C4/Biblio.pm (-13 / +11 lines)
Lines 310-316 sub AddBiblio { Link Here
310
        );
310
        );
311
311
312
        _after_biblio_action_hooks( { action => 'create', biblio_id => $biblionumber } );
312
        _after_biblio_action_hooks( { action => 'create', biblio_id => $biblionumber } );
313
        logaction( "CATALOGUING", "ADD", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
313
        if ( C4::Context->preference("CataloguingLog") ) {
314
            logaction( "CATALOGUING", "ADD", $biblionumber, "biblio", undef, Koha::Biblios->find($biblionumber) );
315
        }
314
316
315
        # We index now, after the transaction is committed
317
        # We index now, after the transaction is committed
316
        unless ($skip_record_index) {
318
        unless ($skip_record_index) {
Lines 395-412 sub ModBiblio { Link Here
395
        return 0;
397
        return 0;
396
    }
398
    }
397
399
400
    my $original;
398
    if ( C4::Context->preference("CataloguingLog") ) {
401
    if ( C4::Context->preference("CataloguingLog") ) {
399
        my $biblio = Koha::Biblios->find($biblionumber);
402
        $original = Koha::Biblios->find($biblionumber)->unblessed;
400
        my $record;
401
        my $decoding_error = "";
402
        eval { $record = $biblio->metadata->record };
403
        if ($@) {
404
            my $exception = $@;
405
            $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
406
            $decoding_error = "There was an error with this bibliographic record: " . $exception;
407
            $record         = $biblio->metadata->record_strip_nonxml;
408
        }
409
        logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio $decoding_error BEFORE=>" . $record->as_formatted );
410
    }
403
    }
411
404
412
    if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) {
405
    if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) {
Lines 469-474 sub ModBiblio { Link Here
469
462
470
    _after_biblio_action_hooks( { action => 'modify', biblio_id => $biblionumber } );
463
    _after_biblio_action_hooks( { action => 'modify', biblio_id => $biblionumber } );
471
464
465
    if ( C4::Context->preference("CataloguingLog") ) {
466
        logaction( "CATALOGUING", "MODIFY", $biblionumber, Koha::Biblios->find($biblionumber), undef, $original );
467
    }
468
472
    # update OAI-PMH sets
469
    # update OAI-PMH sets
473
    if ( C4::Context->preference("OAI-PMH:AutoUpdateSets") ) {
470
    if ( C4::Context->preference("OAI-PMH:AutoUpdateSets") ) {
474
        C4::OAI::Sets::UpdateOAISetsBiblio( $biblionumber, $record );
471
        C4::OAI::Sets::UpdateOAISetsBiblio( $biblionumber, $record );
Lines 588-594 sub DelBiblio { Link Here
588
585
589
    _after_biblio_action_hooks( { action => 'delete', biblio_id => $biblionumber } );
586
    _after_biblio_action_hooks( { action => 'delete', biblio_id => $biblionumber } );
590
587
591
    logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
588
    logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio", undef, $biblio )
589
        if C4::Context->preference("CataloguingLog");
592
590
593
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [$biblionumber] } )
591
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [$biblionumber] } )
594
        unless $params->{skip_holds_queue}
592
        unless $params->{skip_holds_queue}
(-)a/t/db_dependent/Biblio.t (-11 / +5 lines)
Lines 1205-1232 subtest 'GetFrameworkCode' => sub { Link Here
1205
};
1205
};
1206
1206
1207
subtest 'ModBiblio on invalid record' => sub {
1207
subtest 'ModBiblio on invalid record' => sub {
1208
    plan tests => 3;
1208
    plan tests => 2;
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 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' => "00aD000015937" );
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
    C4::Biblio::ModBiblio( $record, $biblionumber, '' );
1220
    qr/parser error : PCDATA invalid Char value 31/,
1221
        'Modding the biblio warns about the encoding issues';
1222
    my $action_logs =
1220
    my $action_logs =
1223
        Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } );
1221
        Koha::ActionLogs->search( { object => $biblionumber, module => 'Cataloguing', action => 'MODIFY' } );
1224
    is( $action_logs->count, 1, "Modification of biblio was successful and recorded" );
1222
    is( $action_logs->count, 1, "Modification of biblio was successful and recorded" );
1225
    my $action_log = $action_logs->next;
1223
    my $action_log = $action_logs->next;
1226
    like(
1224
    like( $action_log->info, qr/biblionumber/, "Biblio data logged in action log info" );
1227
        $action_log->info, qr/parser error : PCDATA invalid Char value 31/,
1228
        "Metadata issue successfully logged in action logs"
1229
    );
1230
};
1225
};
1231
1226
1232
subtest 'UpdateTotalIssues on Invalid record' => sub {
1227
subtest 'UpdateTotalIssues on Invalid record' => sub {
1233
- 

Return to bug 40135