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

(-)a/Koha/Patron/Attribute.pm (-2 / +2 lines)
Lines 61-67 sub store { Link Here
61
        unless $self->unique_ok();
61
        unless $self->unique_ok();
62
62
63
    # Only log for non-repeatable attributes
63
    # Only log for non-repeatable attributes
64
    if (!$self->type->repeatable) {
64
    if (!$self->type->repeatable && C4::Context->preference("BorrowersLog")) {
65
        my $change;
65
        my $change;
66
        if ( exists $deleted_attributes{$self->_deleted_attribute_key} ) {
66
        if ( exists $deleted_attributes{$self->_deleted_attribute_key} ) {
67
            my $previous_attribute = $deleted_attributes{$self->_deleted_attribute_key};
67
            my $previous_attribute = $deleted_attributes{$self->_deleted_attribute_key};
Lines 229-235 Overloaded I<store> method to temporarily stash deleted attribute for action log Link Here
229
229
230
sub delete {
230
sub delete {
231
    my ($self) = @_;
231
    my ($self) = @_;
232
    if (!$self->type->repeatable) {
232
    if (!$self->type->repeatable && C4::Context->preference("BorrowersLog")) {
233
        $deleted_attributes{$self->_deleted_attribute_key} = $self;
233
        $deleted_attributes{$self->_deleted_attribute_key} = $self;
234
    }
234
    }
235
    $self->SUPER::delete();
235
    $self->SUPER::delete();
(-)a/t/db_dependent/Koha/Patron/Attribute.t (-2 / +20 lines)
Lines 23-28 use JSON qw( to_json ); Link Here
23
use Test::More tests => 4;
23
use Test::More tests => 4;
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
26
use Test::Exception;
27
use Test::Exception;
27
28
28
use Koha::Database;
29
use Koha::Database;
Lines 408-414 subtest 'merge_and_replace_with' => sub { Link Here
408
};
409
};
409
410
410
subtest 'action log tests' => sub {
411
subtest 'action log tests' => sub {
411
    plan tests => 3;
412
    plan tests => 4;
412
    my $schema = Koha::Database->new->schema;
413
    my $schema = Koha::Database->new->schema;
413
    $schema->storage->txn_begin;
414
    $schema->storage->txn_begin;
414
415
Lines 420-425 subtest 'action log tests' => sub { Link Here
420
        }
421
        }
421
    );
422
    );
422
423
424
    t::lib::Mocks::mock_preference( 'BorrowersLog', 0 );
423
    my $attributes = [
425
    my $attributes = [
424
        {
426
        {
425
            attribute => 'Foo',
427
            attribute => 'Foo',
Lines 440-445 subtest 'action log tests' => sub { Link Here
440
            info => $info
442
            info => $info
441
        }
443
        }
442
    );
444
    );
445
    is(
446
        $action_logs->count,
447
        0,
448
        'No action log entry has been created when adding patron attribute if BorrowersLog syspref disabled'
449
    );
450
    $patron->extended_attributes([]);
451
452
    t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
453
    $patron->extended_attributes($attributes);
454
    $action_logs = Koha::ActionLogs->search(
455
        {
456
            module => "MEMBERS",
457
            action => "MODIFY",
458
            object => $patron->borrowernumber,
459
            info => $info
460
        }
461
    );
443
    is(
462
    is(
444
        $action_logs->count,
463
        $action_logs->count,
445
        1,
464
        1,
446
- 

Return to bug 26744