Bugzilla – Attachment 130179 Details for
Bug 30023
Add Koha::Old::Checkout->anonymize
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30023: Make MarkIssueReturned use ->anonymize
Bug-30023-Make-MarkIssueReturned-use--anonymize.patch (text/plain), 3.51 KB, created by
David Nind
on 2022-02-04 19:43:26 UTC
(
hide
)
Description:
Bug 30023: Make MarkIssueReturned use ->anonymize
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-02-04 19:43:26 UTC
Size:
3.51 KB
patch
obsolete
>From bc2c58d75729fd659921d6635cca90db6e3b5017 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 4 Feb 2022 08:47:05 -0300 >Subject: [PATCH] Bug 30023: Make MarkIssueReturned use ->anonymize > >Koha::Old::Checkout->anonymize takes care of checking the syspref and >raises an exception if not set. So no we can now leverage on it, instead >of checking manually and then tweaking the checkout object manually as >well. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Circulation/MarkIssueReturned.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Circulation.pm | 13 +------------ > t/db_dependent/Circulation/MarkIssueReturned.t | 11 ++++++++--- > 2 files changed, 9 insertions(+), 15 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index d59fbf6380..0e380d93d6 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2359,17 +2359,6 @@ sub MarkIssueReturned { > > my $issue_id = $issue->issue_id; > >- my $anonymouspatron; >- if ( $privacy && $privacy == 2 ) { >- # The default of 0 will not work due to foreign key constraints >- # The anonymisation will fail if AnonymousPatron is not a valid entry >- # We need to check if the anonymous patron exist, Koha will fail loudly if it does not >- # Note that a warning should appear on the about page (System information tab). >- $anonymouspatron = C4::Context->preference('AnonymousPatron'); >- die "Fatal error: the patron ($borrowernumber) has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or not set correctly." >- unless Koha::Patrons->find( $anonymouspatron ); >- } >- > my $schema = Koha::Database->schema; > > # FIXME Improve the return value and handle it from callers >@@ -2390,7 +2379,7 @@ sub MarkIssueReturned { > > # anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber > if ( $privacy && $privacy == 2) { >- $old_checkout->borrowernumber($anonymouspatron)->store; >+ $old_checkout->anonymize; > } > > # And finally delete the issue >diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t >index 094276ffb4..654ac37451 100755 >--- a/t/db_dependent/Circulation/MarkIssueReturned.t >+++ b/t/db_dependent/Circulation/MarkIssueReturned.t >@@ -76,7 +76,7 @@ subtest 'Failure tests' => sub { > > subtest 'Anonymous patron tests' => sub { > >- plan tests => 2; >+ plan tests => 3; > > $schema->storage->txn_begin; > >@@ -99,8 +99,13 @@ subtest 'Anonymous patron tests' => sub { > t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); > > my $issue = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); >- eval { C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 2 ) }; >- like ( $@, qr<Fatal error: the patron \(\d+\) .* AnonymousPatron>, 'AnonymousPatron is not set - Fatal error on anonymization' ); >+ >+ throws_ok >+ { C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 2 ); } >+ 'Koha::Exceptions::SysPref::NotSet', >+ 'AnonymousPatron not set causes an exception'; >+ >+ is( $@->syspref, 'AnonymousPatron', 'AnonymousPatron is not set - Fatal error on anonymization' ); > Koha::Checkouts->find( $issue->issue_id )->delete; > > # Create a valid anonymous user >-- >2.30.2
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 30023
:
130161
|
130162
|
130178
|
130179
|
130277
|
130278