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

(-)a/C4/Log.pm (-2 / +11 lines)
Lines 118-126 sub logaction { Link Here
118
    }
118
    }
119
    my $trace = @trace ? to_json( \@trace, { utf8 => 1, pretty => 0 } ) : undef;
119
    my $trace = @trace ? to_json( \@trace, { utf8 => 1, pretty => 0 } ) : undef;
120
120
121
    my $is_object = blessed($original) && $original->isa('Koha::Object');
122
123
    if ( $actionname =~ /^(ADD|CREATE)$/ ) {
124
        # Log diff against empty hashref for newly created objects
125
        $updated = $is_object ? $original->unblessed : $original;
126
        $original = {};
127
    } else {
128
        # Log diff against hashref of pre-modified object if passed in
129
        $original = $is_object ? $original->unblessed : $original;
130
    }
131
121
    my $diff = undef;
132
    my $diff = undef;
122
    $diff = encode_json( diff( $original->unblessed, $updated, noU => 1 ) )
123
        if blessed($original) && $original->isa('Koha::Object');
124
    $diff //= encode_json( diff( $original, $updated, noU => 1 ) )
133
    $diff //= encode_json( diff( $original, $updated, noU => 1 ) )
125
        if $original && ref $updated eq 'HASH';
134
        if $original && ref $updated eq 'HASH';
126
135
(-)a/Koha/Item.pm (-3 / +3 lines)
Lines 222-236 sub store { Link Here
222
222
223
    my $original = Koha::Items->find( $self->itemnumber );    # $original will be undef if $action eq 'create'
223
    my $original = Koha::Items->find( $self->itemnumber );    # $original will be undef if $action eq 'create'
224
    my $result = $self->SUPER::store;
224
    my $result = $self->SUPER::store;
225
    $self->discard_changes;
225
    if ( $log_action && C4::Context->preference("CataloguingLog") ) {
226
    if ( $log_action && C4::Context->preference("CataloguingLog") ) {
226
        $action eq 'create'
227
        $action eq 'create'
227
            ? logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
228
            ? logaction( "CATALOGUING", "ADD", $self->itemnumber, 'item', undef, $self )
228
            : logaction( "CATALOGUING", "MODIFY", $self->itemnumber, $self, undef, $original );
229
            : logaction( "CATALOGUING", "MODIFY", $self->itemnumber, $self, undef, $original );
229
    }
230
    }
230
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
231
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
231
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
232
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
232
        unless $params->{skip_record_index};
233
        unless $params->{skip_record_index};
233
    $self->get_from_storage->_after_item_action_hooks({ action => $action });
234
    $self->_after_item_action_hooks({ action => $action });
234
235
235
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
236
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
236
        {
237
        {
237
- 

Return to bug 37943