Bugzilla – Attachment 127350 Details for
Bug 29341
If OpacRenewalBranch = opacrenew, pseudonymization process leads to "internal server error" when patrons renew the loans at OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29341: Prevent OPAC renew to crash if Pseudonymization is set
Bug-29341-Prevent-OPAC-renew-to-crash-if-Pseudonym.patch (text/plain), 3.70 KB, created by
Marcel de Rooy
on 2021-11-05 10:17:06 UTC
(
hide
)
Description:
Bug 29341: Prevent OPAC renew to crash if Pseudonymization is set
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2021-11-05 10:17:06 UTC
Size:
3.70 KB
patch
obsolete
>From bb3a3d6d0430895d8485d19d0988676c0264c681 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 28 Oct 2021 11:29:01 +0200 >Subject: [PATCH] Bug 29341: Prevent OPAC renew to crash if Pseudonymization is > set >Content-Type: text/plain; charset=utf-8 > >If OpacRenewalBranch = opacrenew then we try to insert a wrong >branchcode into pseudonymized_transactions.transaction_branchcode > >We are trying to insert 'OPACRenew' > >Test plan: >Setup Pseudonymization >Set OpacRenewalBranch = opacrenew >Renew an item from the OPAC >Notice that pseudonymized_transactions.transaction_branchcode is set to >NULL > >Signed-off-by: David Nind <david@davidnind.com> > >[SQUASHED] Bug 29341: Don't modify the branchcode for stats > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >[EDIT] >Amended test for 'as is' and a reference to OPACRenew in test script. >--- > C4/Stats.pm | 4 +++ > t/db_dependent/Koha/Pseudonymization.t | 39 +++++++++++++++++++++++++- > 2 files changed, 42 insertions(+), 1 deletion(-) > >diff --git a/C4/Stats.pm b/C4/Stats.pm >index 1b883d2de1..94e5dbf52d 100644 >--- a/C4/Stats.pm >+++ b/C4/Stats.pm >@@ -140,6 +140,10 @@ sub UpdateStats { > } > )->store; > >+ >+ # If $branch is set to an invalid branchcode, like 'OPACRenew' >+ $statistic->branch(undef) if $branch && ! Koha::Libraries->find($branch); >+ > Koha::PseudonymizedTransaction->new_from_statistic($statistic)->store > if C4::Context->preference('Pseudonymization') > && $borrowernumber # Not a real transaction if the patron does not exist >diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t >index 674ad36bf1..949de130c6 100755 >--- a/t/db_dependent/Koha/Pseudonymization.t >+++ b/t/db_dependent/Koha/Pseudonymization.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 4; > use Try::Tiny; > > use C4::Circulation qw( AddIssue AddReturn ); >@@ -29,6 +29,7 @@ use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Patrons; > use Koha::PseudonymizedTransactions; >+use Koha::Statistics; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -209,3 +210,39 @@ subtest 'PseudonymizedBorrowerAttributes tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'invalid branchcode' => sub { # Test added for transaction_branchcode == 'OPACRenew' (BZ 29341) >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_config( 'bcrypt_settings', '$2a$08$9lmorEKnwQloheaCLFIfje' ); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ t::lib::Mocks::mock_preference( 'Pseudonymization', 1 ); >+ my $item = $builder->build_sample_item; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branchcode = $library->branchcode; >+ $library->delete; >+ >+ C4::Stats::UpdateStats( >+ { >+ type => 'issue', >+ branch => $branchcode, >+ itemnumber => $item->itemnumber, >+ borrowernumber => $patron->borrowernumber, >+ itemtype => $item->effective_itemtype, >+ location => $item->location, >+ ccode => $item->ccode, >+ } >+ ); >+ >+ my $stat = Koha::Statistics->search({itemnumber => $item->itemnumber}); >+ is( $stat->next->branch, $branchcode, 'UpdateStats does not explode if branchcode is invalid, and stat logs the branchcode as is' ); >+ >+ my $p = Koha::PseudonymizedTransactions->search({itemnumber => $item->itemnumber}); >+ is( $p->next->transaction_branchcode, undef, 'Pseudonymized transactions logged branchcode=NULL if invalid branchcode passed' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29341
:
127034
|
127078
|
127213
|
127350
|
127727
|
127848