View | Details | Raw Unified | Return to bug 24114
Collapse All | Expand All

(-)a/Koha/Patrons.pm (-13 / +4 lines)
Lines 202-208 sub anonymise_issue_history { Link Here
202
202
203
=head3 delete
203
=head3 delete
204
204
205
    Koha::Patrons->search({ some filters here })->delete({ move => 1, verbose => 1 });
205
    Koha::Patrons->search({ some filters here })->delete({ move => 1 });
206
206
207
    Delete passed set of patron objects.
207
    Delete passed set of patron objects.
208
    Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron
208
    Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron
Lines 229-235 sub delete { Link Here
229
229
230
            $patrons_deleted++;
230
            $patrons_deleted++;
231
        }
231
        }
232
        warn "Deleted $count patrons\n" if $params->{verbose};
233
    }, $self, $params );
232
    }, $self, $params );
234
    return $patrons_deleted;
233
    return $patrons_deleted;
235
}
234
}
Lines 326-335 sub search_anonymized { Link Here
326
325
327
=head3 lock
326
=head3 lock
328
327
329
    Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1, verbose => 1 })
328
    Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1 })
330
329
331
    Lock the passed set of patron objects. Optionally expire and remove holds.
330
    Lock the passed set of patron objects. Optionally expire and remove holds.
332
    Optional verbose flag is used in cron job.
333
    Wrapper around Koha::Patron->lock.
331
    Wrapper around Koha::Patron->lock.
334
332
335
=cut
333
=cut
Lines 340-369 sub lock { Link Here
340
    while( my $patron = $self->next ) {
338
    while( my $patron = $self->next ) {
341
        $patron->lock($params);
339
        $patron->lock($params);
342
    }
340
    }
343
    if( $params->{verbose} ) {
344
        warn "Locked $count patrons\n";
345
    }
346
}
341
}
347
342
348
=head3 anonymize
343
=head3 anonymize
349
344
350
    Koha::Patrons->search({ some filters })->anonymize({ verbose => 1 });
345
    Koha::Patrons->search({ some filters })->anonymize();
351
346
352
    Anonymize passed set of patron objects.
347
    Anonymize passed set of patron objects.
353
    Optional verbose flag is used in cron job.
354
    Wrapper around Koha::Patron->anonymize.
348
    Wrapper around Koha::Patron->anonymize.
355
349
356
=cut
350
=cut
357
351
358
sub anonymize {
352
sub anonymize {
359
    my ( $self, $params ) = @_;
353
    my ( $self ) = @_;
360
    my $count = $self->count;
354
    my $count = $self->count;
361
    while( my $patron = $self->next ) {
355
    while( my $patron = $self->next ) {
362
        $patron->anonymize;
356
        $patron->anonymize;
363
    }
357
    }
364
    if( $params->{verbose} ) {
365
        warn "Anonymized $count patrons\n";
366
    }
367
}
358
}
368
359
369
=head3 search_patrons_to_update_category
360
=head3 search_patrons_to_update_category
(-)a/misc/cronjobs/cleanup_database.pl (-5 / +16 lines)
Lines 331-342 if($allDebarments) { Link Here
331
}
331
}
332
332
333
# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference
333
# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference
334
Koha::Patrons->search_unsubscribed->lock({ expire => 1, remove => 1, verbose => $verbose });
334
my $unsubscribed_patrons = Koha::Patrons->search_unsubscribed;
335
$unsubscribed_patrons->lock( { expire => 1, remove => 1 } );
336
say sprintf "Locked %d patrons", $unsubscribed_patrons->count if $verbose;
337
335
# Anonymize patron data, depending on PatronAnonymizeDelay
338
# Anonymize patron data, depending on PatronAnonymizeDelay
336
Koha::Patrons->search_anonymize_candidates({ locked => 1 })->anonymize({ verbose => $verbose });
339
my $anonymize_candidates = Koha::Patrons->search_anonymize_candidates( { locked => 1 } );
340
$anonymize_candidates->anonymize;
341
say sprintf "Anonymized %s patrons", $anonymize_candidates->count if $verbose;
342
337
# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered
343
# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered
338
eval { Koha::Patrons->search_anonymized->delete({ move => 1, verbose => $verbose }) };
344
my $anonymized_patrons = Koha::Patrons->search_anonymized;
339
warn $@ if $@;
345
$anonymized_patrons->delete( { move => 1 } );
346
if ($@) {
347
    warn $@;
348
}
349
elsif ($verbose) {
350
    say sprintf "Deleted %d patrons", $anonymized_patrons->count;
351
}
340
352
341
if( $pExpSelfReg ) {
353
if( $pExpSelfReg ) {
342
    DeleteExpiredSelfRegs();
354
    DeleteExpiredSelfRegs();
343
- 

Return to bug 24114