Bug 39322: Don't fetch borrower attributes if none kept for pseudonymization

This patch simply checks the count of pseudonymized borrower attributes before
looping through them

To test:
 1 - Define several borrower attributes, none kept for pseudonymization
 2 - Add some values for those attributes to some patrons
 3 - Generate some statistics for those patrons (checkin, checkout, renew, etc)
 4 - Enable pseudonymization
 5 - On command line: export DBIC_TRACE=1
 6 - Run the pseudonymization script with a date in the future to ensure all transactions are captured:
    perl misc/maintenance/pseudonymize_statistics.pl -v -c --before 2026-01-01
 7 - Note the borrower attributes are fetched
 8 - Apply patch
 9 - repeat 6
10 - Note the attributes are only counted, not fetched
11 - Make one of the attributes kept
12 - repeat 6
13 - Note the attributes are counted and fetched

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2025-03-13 13:09:59 +00:00 committed by Katrin Fischer
parent 85f9e30ed5
commit 10b84d9df4
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 1 additions and 1 deletions

View File

@ -98,7 +98,7 @@ sub create_from_statistic {
$self->store();
if ($patron) {
if ( $patron && Koha::Patron::Attribute::Types->search( { keep_for_pseudonymization => 1 } )->count > 0 ) {
my $extended_attributes = $patron->extended_attributes->unblessed;
for my $attribute (@$extended_attributes) {
next unless Koha::Patron::Attribute::Types->find( $attribute->{code} )->keep_for_pseudonymization;