Bugzilla – Attachment 127034 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.17 KB, created by
Jonathan Druart
on 2021-10-28 09:31:47 UTC
(
hide
)
Description:
Bug 29341: Prevent OPAC renew to crash if Pseudonymization is set
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-10-28 09:31:47 UTC
Size:
3.17 KB
patch
obsolete
>From 984faae42fa533797997ef60061986b7be4c451d 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 > >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 >--- > C4/Stats.pm | 3 +++ > t/db_dependent/Koha/Pseudonymization.t | 36 +++++++++++++++++++++++++- > 2 files changed, 38 insertions(+), 1 deletion(-) > >diff --git a/C4/Stats.pm b/C4/Stats.pm >index 1b883d2de18..352e4f92a0b 100644 >--- a/C4/Stats.pm >+++ b/C4/Stats.pm >@@ -124,6 +124,9 @@ sub UpdateStats { > my $location = exists $params->{location} ? $params->{location} : undef; > my $ccode = exists $params->{ccode} ? $params->{ccode} : ''; > >+ # If $branch is set to an invalid branchcode, like 'OPACRenew' >+ $branch = undef if $branch && ! Koha::Libraries->find($branch); >+ > my $dtf = Koha::Database->new->schema->storage->datetime_parser; > my $statistic = Koha::Statistic->new( > { >diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t >index 674ad36bf1a..4ca12e1cbc9 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,36 @@ subtest 'PseudonymizedBorrowerAttributes tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'invalid branchcode' => sub { >+ plan tests => 1; >+ >+ $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, undef, 'UpdateStats does not explode if branchcode is invalid' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.25.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