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 225-231 sub delete { Link Here
225
            $patron->delete == 1 || Koha::Exceptions::Patron::FailedDelete->throw;
225
            $patron->delete == 1 || Koha::Exceptions::Patron::FailedDelete->throw;
226
            $patrons_deleted++;
226
            $patrons_deleted++;
227
        }
227
        }
228
        warn "Deleted $count patrons\n" if $params->{verbose};
229
    }, $self, $params );
228
    }, $self, $params );
230
    return $patrons_deleted;
229
    return $patrons_deleted;
231
}
230
}
Lines 322-331 sub search_anonymized { Link Here
322
321
323
=head3 lock
322
=head3 lock
324
323
325
    Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1, verbose => 1 })
324
    Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1 })
326
325
327
    Lock the passed set of patron objects. Optionally expire and remove holds.
326
    Lock the passed set of patron objects. Optionally expire and remove holds.
328
    Optional verbose flag is used in cron job.
329
    Wrapper around Koha::Patron->lock.
327
    Wrapper around Koha::Patron->lock.
330
328
331
=cut
329
=cut
Lines 336-365 sub lock { Link Here
336
    while( my $patron = $self->next ) {
334
    while( my $patron = $self->next ) {
337
        $patron->lock($params);
335
        $patron->lock($params);
338
    }
336
    }
339
    if( $params->{verbose} ) {
340
        warn "Locked $count patrons\n";
341
    }
342
}
337
}
343
338
344
=head3 anonymize
339
=head3 anonymize
345
340
346
    Koha::Patrons->search({ some filters })->anonymize({ verbose => 1 });
341
    Koha::Patrons->search({ some filters })->anonymize();
347
342
348
    Anonymize passed set of patron objects.
343
    Anonymize passed set of patron objects.
349
    Optional verbose flag is used in cron job.
350
    Wrapper around Koha::Patron->anonymize.
344
    Wrapper around Koha::Patron->anonymize.
351
345
352
=cut
346
=cut
353
347
354
sub anonymize {
348
sub anonymize {
355
    my ( $self, $params ) = @_;
349
    my ( $self ) = @_;
356
    my $count = $self->count;
350
    my $count = $self->count;
357
    while( my $patron = $self->next ) {
351
    while( my $patron = $self->next ) {
358
        $patron->anonymize;
352
        $patron->anonymize;
359
    }
353
    }
360
    if( $params->{verbose} ) {
361
        warn "Anonymized $count patrons\n";
362
    }
363
}
354
}
364
355
365
=head3 search_patrons_to_update_category
356
=head3 search_patrons_to_update_category
(-)a/misc/cronjobs/cleanup_database.pl (-5 / +16 lines)
Lines 306-317 if($allDebarments) { Link Here
306
}
306
}
307
307
308
# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference
308
# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference
309
Koha::Patrons->search_unsubscribed->lock({ expire => 1, remove => 1, verbose => $verbose });
309
my $unsubscribed_patrons = Koha::Patrons->search_unsubscribed;
310
$unsubscribed_patrons->lock( { expire => 1, remove => 1 } );
311
say sprintf "Locked %d patrons", $unsubscribed_patrons->count if $verbose;
312
310
# Anonymize patron data, depending on PatronAnonymizeDelay
313
# Anonymize patron data, depending on PatronAnonymizeDelay
311
Koha::Patrons->search_anonymize_candidates({ locked => 1 })->anonymize({ verbose => $verbose });
314
my $anonymize_candidates = Koha::Patrons->search_anonymize_candidates( { locked => 1 } );
315
$anonymize_candidates->anonymize;
316
say sprintf "Anonymized %s patrons", $anonymize_candidates->count if $verbose;
317
312
# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered
318
# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered
313
eval { Koha::Patrons->search_anonymized->delete({ move => 1, verbose => $verbose }) };
319
my $anonymized_patrons = Koha::Patrons->search_anonymized;
314
warn $@ if $@;
320
$anonymized_patrons->delete( { move => 1 } );
321
if ($@) {
322
    warn $@;
323
}
324
elsif ($verbose) {
325
    say sprintf "Deleted %d patrons", $anonymized_patrons->count;
326
}
315
327
316
if( $pExpSelfReg ) {
328
if( $pExpSelfReg ) {
317
    DeleteExpiredSelfRegs();
329
    DeleteExpiredSelfRegs();
318
- 

Return to bug 24114