From e654a1b1009b6ff88570f9944d23d39933a1b0f6 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 3 Jan 2022 10:37:09 -0300 Subject: [PATCH] Bug 29780: Add Koha::Old::Holds->anonymize This patch adds a handy method for anonymizing a Koha::Old::Holds resultset. It is planned to be used on bug 29526. To test: 1. Apply this patches 2. Run: $ kshell k$ prove t/db_dependent/Koha/Old/Holds.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Lucas Gass Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- Koha/Old/Holds.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Koha/Old/Holds.pm b/Koha/Old/Holds.pm index 415c4c9b7e..40bf2dcdf2 100644 --- a/Koha/Old/Holds.pm +++ b/Koha/Old/Holds.pm @@ -34,11 +34,27 @@ This object represents a set of holds that have been filled or canceled =head1 API -=head2 Class Methods +=head2 Class methods + +=head3 anonymize + + $patron->old_holds->anonymize(); + +Anonymize the given I resultset. =cut -=head3 type +sub anonymize { + my ( $self, $params ) = @_; + + my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef; + + return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } ); +} + +=head2 Internal methods + +=head3 _type =cut -- 2.39.5