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

(-)a/C4/Biblio.pm (-4 / +4 lines)
Lines 315-321 sub AddBiblio { Link Here
315
            my $marc_for_log = eval { $new_biblio->metadata->record_strip_nonxml };
315
            my $marc_for_log = eval { $new_biblio->metadata->record_strip_nonxml };
316
            logaction(
316
            logaction(
317
                "CATALOGUING", "ADD", $biblionumber, "biblio", undef,
317
                "CATALOGUING", "ADD", $biblionumber, "biblio", undef,
318
                { %{ $new_biblio->unblessed }, _marc => _marc_record_to_diffable($marc_for_log) }
318
                { %{ $new_biblio->_unblessed_for_log }, _marc => _marc_record_to_diffable($marc_for_log) }
319
            );
319
            );
320
        }
320
        }
321
321
Lines 405-411 sub ModBiblio { Link Here
405
    my ( $original, $original_marc );
405
    my ( $original, $original_marc );
406
    if ( C4::Context->preference("CataloguingLog") ) {
406
    if ( C4::Context->preference("CataloguingLog") ) {
407
        my $pre_biblio = Koha::Biblios->find($biblionumber);
407
        my $pre_biblio = Koha::Biblios->find($biblionumber);
408
        $original      = $pre_biblio->unblessed;
408
        $original      = $pre_biblio->_unblessed_for_log;
409
        $original_marc = eval { $pre_biblio->metadata->record_strip_nonxml };
409
        $original_marc = eval { $pre_biblio->metadata->record_strip_nonxml };
410
    }
410
    }
411
411
Lines 474-480 sub ModBiblio { Link Here
474
        my $updated_marc_log = eval { $updated_biblio->metadata->record_strip_nonxml };
474
        my $updated_marc_log = eval { $updated_biblio->metadata->record_strip_nonxml };
475
        logaction(
475
        logaction(
476
            "CATALOGUING", "MODIFY", $biblionumber,
476
            "CATALOGUING", "MODIFY", $biblionumber,
477
            { %{ $updated_biblio->unblessed }, _marc => _marc_record_to_diffable($updated_marc_log) },
477
            { %{ $updated_biblio->_unblessed_for_log }, _marc => _marc_record_to_diffable($updated_marc_log) },
478
            undef,
478
            undef,
479
            { %{$original}, _marc => _marc_record_to_diffable($original_marc) }
479
            { %{$original}, _marc => _marc_record_to_diffable($original_marc) }
480
        );
480
        );
Lines 627-633 sub DelBiblio { Link Here
627
627
628
    logaction(
628
    logaction(
629
        "CATALOGUING", "DELETE", $biblionumber, "biblio", undef,
629
        "CATALOGUING", "DELETE", $biblionumber, "biblio", undef,
630
        { %{ $biblio->unblessed }, _marc => _marc_record_to_diffable($biblio_marc) }
630
        { %{ $biblio->_unblessed_for_log }, _marc => _marc_record_to_diffable($biblio_marc) }
631
    ) if C4::Context->preference("CataloguingLog");
631
    ) if C4::Context->preference("CataloguingLog");
632
632
633
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [$biblionumber] } )
633
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [$biblionumber] } )
(-)a/Koha/Biblio.pm (-1 / +24 lines)
Lines 20-25 package Koha::Biblio; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use List::MoreUtils qw( any );
22
use List::MoreUtils qw( any );
23
use Scalar::Util    qw( blessed );
23
use URI;
24
use URI;
24
use URI::Escape qw( uri_escape_utf8 );
25
use URI::Escape qw( uri_escape_utf8 );
25
use Try::Tiny;
26
use Try::Tiny;
Lines 2402-2407 sub merge_with { Link Here
2402
2403
2403
=head2 Internal methods
2404
=head2 Internal methods
2404
2405
2406
=head3 _unblessed_for_log
2407
2408
Returns a plain hashref of biblio column values safe for JSON serialisation
2409
and action log diffing. Timestamp is excluded as it changes on every write,
2410
and undef/empty-string fields are removed so that genuinely unset columns
2411
do not produce noise in diffs.
2412
2413
=cut
2414
2415
sub _unblessed_for_log {
2416
    my ($self) = @_;
2417
    my $data = $self->unblessed;
2418
    delete $data->{timestamp};
2419
    for my $key ( keys %$data ) {
2420
        if ( defined $data->{$key} && $data->{$key} ne '' ) {
2421
            $data->{$key} = "$data->{$key}" if blessed( $data->{$key} );
2422
        } else {
2423
            delete $data->{$key};
2424
        }
2425
    }
2426
    return $data;
2427
}
2428
2405
=head3 type
2429
=head3 type
2406
2430
2407
=cut
2431
=cut
2408
- 

Return to bug 40135