Bugzilla – Attachment 130274 Details for
Bug 30007
Make ->anonymize methods throw an exception if AnonymousPatron is not set
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30007: Make ->anonymize methods throw an exception if AnonymousPatron is not set
Bug-30007-Make--anonymize-methods-throw-an-excepti.patch (text/plain), 2.94 KB, created by
Martin Renvoize (ashimema)
on 2022-02-08 09:48:24 UTC
(
hide
)
Description:
Bug 30007: Make ->anonymize methods throw an exception if AnonymousPatron is not set
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-02-08 09:48:24 UTC
Size:
2.94 KB
patch
obsolete
>From b6734267d2bb410134c6d28c1352d06615cadd02 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 4 Feb 2022 08:15:06 -0300 >Subject: [PATCH] Bug 30007: Make ->anonymize methods throw an exception if > AnonymousPatron is not set > >This patch makes the ->anonymize methods throw a >Koha::Exceptions::SysPref::NotSet exception when trying to anonymize >holds and checkouts without AnonymousPatron properly set. > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Old/Checkouts.t \ > t/db_dependent/Koha/Old/Holds.t \ > t/db_dependent/Koha/Old/Hold.t >=> FAIL: Tests fail, no exception thrown >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >https://bugs.koha-community.org/show_bug.cgi?id=3007 >--- > Koha/Old/Checkouts.pm | 5 ++++- > Koha/Old/Hold.pm | 6 +++++- > Koha/Old/Holds.pm | 5 ++++- > 3 files changed, 13 insertions(+), 3 deletions(-) > >diff --git a/Koha/Old/Checkouts.pm b/Koha/Old/Checkouts.pm >index 5ba2bec6d2..8ee651645f 100644 >--- a/Koha/Old/Checkouts.pm >+++ b/Koha/Old/Checkouts.pm >@@ -96,7 +96,10 @@ Anonymize the given I<Koha::Old::Checkouts> resultset. > sub anonymize { > my ( $self, $params ) = @_; > >- my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; >+ my $anonymous_id = C4::Context->preference('AnonymousPatron'); >+ >+ Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' ) >+ unless $anonymous_id; > > return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } ); > } >diff --git a/Koha/Old/Hold.pm b/Koha/Old/Hold.pm >index 33642b33f6..aa164fcd2a 100644 >--- a/Koha/Old/Hold.pm >+++ b/Koha/Old/Hold.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use base qw(Koha::Hold); > > use C4::Context; >+use Koha::Exceptions::SysPref; > > =head1 NAME > >@@ -44,7 +45,10 @@ Anonymize the given I<Koha::Old::Hold> object. > sub anonymize { > my ($self) = @_; > >- my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; >+ my $anonymous_id = C4::Context->preference('AnonymousPatron'); >+ >+ Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' ) >+ unless $anonymous_id; > > return $self->update( { borrowernumber => $anonymous_id } ); > } >diff --git a/Koha/Old/Holds.pm b/Koha/Old/Holds.pm >index 1a7cb0d5a7..d3aad2ee89 100644 >--- a/Koha/Old/Holds.pm >+++ b/Koha/Old/Holds.pm >@@ -78,7 +78,10 @@ Anonymize the given I<Koha::Old::Holds> resultset. > sub anonymize { > my ( $self, $params ) = @_; > >- my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; >+ my $anonymous_id = C4::Context->preference('AnonymousPatron'); >+ >+ Koha::Exceptions::SysPref::NotSet->throw( syspref => 'AnonymousPatron' ) >+ unless $anonymous_id; > > return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } ); > } >-- >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 30007
:
130163
|
130164
|
130165
|
130175
|
130176
|
130177
|
130272
|
130273
| 130274 |
131239
|
131298