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

(-)a/C4/Stats.pm (-3 / +4 lines)
Lines 124-132 sub UpdateStats { Link Here
124
    my $location          = exists $params->{location}       ? $params->{location}       : undef;
124
    my $location          = exists $params->{location}       ? $params->{location}       : undef;
125
    my $ccode             = exists $params->{ccode}          ? $params->{ccode}          : '';
125
    my $ccode             = exists $params->{ccode}          ? $params->{ccode}          : '';
126
126
127
    # If $branch is set to an invalid branchcode, like 'OPACRenew'
128
    $branch = undef if $branch && ! Koha::Libraries->find($branch);
129
130
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
127
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
131
    my $statistic = Koha::Statistic->new(
128
    my $statistic = Koha::Statistic->new(
132
        {
129
        {
Lines 143-148 sub UpdateStats { Link Here
143
        }
140
        }
144
    )->store;
141
    )->store;
145
142
143
144
    # If $branch is set to an invalid branchcode, like 'OPACRenew'
145
    $statistic->branch(undef) if $branch && ! Koha::Libraries->find($branch);
146
146
    Koha::PseudonymizedTransaction->new_from_statistic($statistic)->store
147
    Koha::PseudonymizedTransaction->new_from_statistic($statistic)->store
147
      if C4::Context->preference('Pseudonymization')
148
      if C4::Context->preference('Pseudonymization')
148
        && $borrowernumber # Not a real transaction if the patron does not exist
149
        && $borrowernumber # Not a real transaction if the patron does not exist
(-)a/t/db_dependent/Koha/Pseudonymization.t (-3 / +5 lines)
Lines 212-218 subtest 'PseudonymizedBorrowerAttributes tests' => sub { Link Here
212
};
212
};
213
213
214
subtest 'invalid branchcode' => sub {
214
subtest 'invalid branchcode' => sub {
215
    plan tests => 1;
215
    plan tests => 2;
216
216
217
    $schema->storage->txn_begin;
217
    $schema->storage->txn_begin;
218
218
Lines 239-245 subtest 'invalid branchcode' => sub { Link Here
239
    );
239
    );
240
240
241
    my $stat = Koha::Statistics->search({itemnumber => $item->itemnumber});
241
    my $stat = Koha::Statistics->search({itemnumber => $item->itemnumber});
242
    is( $stat->next->branch, undef, 'UpdateStats does not explode if branchcode is invalid' );
242
    is( $stat->next->branch, $branchcode, 'UpdateStats does not explode if branchcode is invalid, and stat logs the branchcode as it' );
243
244
    my $p = Koha::PseudonymizedTransactions->search({itemnumber => $item->itemnumber});
245
    is( $p->next->transaction_branchcode, undef, 'Pseudonymized transactions logged branchcode=NULL if invalid branchcode passed' );
243
246
244
    $schema->storage->txn_rollback;
247
    $schema->storage->txn_rollback;
245
};
248
};
246
- 

Return to bug 29341