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

(-)a/Koha/Patrons.pm (-4 / +16 lines)
Lines 210-216 sub anonymise_issue_history { Link Here
210
210
211
=head3 delete
211
=head3 delete
212
212
213
    Koha::Patrons->search({ some filters here })->delete({ move => 1 });
213
    Koha::Patrons->search({ some filters here })->delete({ move => 1, verbose => 1 });
214
214
215
    Delete passed set of patron objects.
215
    Delete passed set of patron objects.
216
    Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron
216
    Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron
Lines 227-237 sub delete { Link Here
227
    my $patrons_deleted;
227
    my $patrons_deleted;
228
    $self->_resultset->result_source->schema->txn_do( sub {
228
    $self->_resultset->result_source->schema->txn_do( sub {
229
        my ( $set, $params ) = @_;
229
        my ( $set, $params ) = @_;
230
        my $count = $set->count;
230
        while( my $patron = $set->next ) {
231
        while( my $patron = $set->next ) {
231
            $patron->move_to_deleted if $params->{move};
232
            $patron->move_to_deleted if $params->{move};
232
            $patron->delete == 1 || Koha::Exceptions::Patron::FailedDelete->throw;
233
            $patron->delete == 1 || Koha::Exceptions::Patron::FailedDelete->throw;
233
            $patrons_deleted++;
234
            $patrons_deleted++;
234
        }
235
        }
236
        warn "Deleted $count patrons\n" if $params->{verbose};
235
    }, $self, $params );
237
    }, $self, $params );
236
    return $patrons_deleted;
238
    return $patrons_deleted;
237
}
239
}
Lines 328-361 sub search_anonymized { Link Here
328
330
329
=head3 lock
331
=head3 lock
330
332
331
    Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1 })
333
    Koha::Patrons->search({ some filters })->lock({ expire => 1, remove => 1, verbose => 1 })
332
334
333
    Lock the passed set of patron objects. Optionally expire and remove holds.
335
    Lock the passed set of patron objects. Optionally expire and remove holds.
336
    Optional verbose flag is used in cron job.
334
    Wrapper around Koha::Patron->lock.
337
    Wrapper around Koha::Patron->lock.
335
338
336
=cut
339
=cut
337
340
338
sub lock {
341
sub lock {
339
    my ( $self, $params ) = @_;
342
    my ( $self, $params ) = @_;
343
    my $count = $self->count;
340
    while( my $patron = $self->next ) {
344
    while( my $patron = $self->next ) {
341
        $patron->lock($params);
345
        $patron->lock($params);
342
    }
346
    }
347
    if( $params->{verbose} ) {
348
        warn "Locked $count patrons\n";
349
    }
343
}
350
}
344
351
345
=head3 anonymize
352
=head3 anonymize
346
353
347
    Koha::Patrons->search({ some filters })->anonymize;
354
    Koha::Patrons->search({ some filters })->anonymize({ verbose => 1 });
348
355
349
    Anonymize passed set of patron objects.
356
    Anonymize passed set of patron objects.
357
    Optional verbose flag is used in cron job.
350
    Wrapper around Koha::Patron->anonymize.
358
    Wrapper around Koha::Patron->anonymize.
351
359
352
=cut
360
=cut
353
361
354
sub anonymize {
362
sub anonymize {
355
    my ( $self ) = @_;
363
    my ( $self, $params ) = @_;
364
    my $count = $self->count;
356
    while( my $patron = $self->next ) {
365
    while( my $patron = $self->next ) {
357
        $patron->anonymize;
366
        $patron->anonymize;
358
    }
367
    }
368
    if( $params->{verbose} ) {
369
        warn "Anonymized $count patrons\n";
370
    }
359
}
371
}
360
372
361
=head3 _type
373
=head3 _type
(-)a/misc/cronjobs/cleanup_database.pl (-1 / +8 lines)
Lines 304-309 if($allDebarments) { Link Here
304
    print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose;
304
    print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose;
305
}
305
}
306
306
307
# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference
308
Koha::Patrons->search_unsubscribed->lock({ expire => 1, remove => 1, verbose => $verbose });
309
# Anonymize patron data, depending on PatronAnonymizeDelay
310
Koha::Patrons->search_anonymize_candidates({ locked => 1 })->anonymize({ verbose => $verbose });
311
# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered
312
eval { Koha::Patrons->search_anonymized->delete({ move => 1, verbose => $verbose }) };
313
warn $@ if $@;
314
307
if( $pExpSelfReg ) {
315
if( $pExpSelfReg ) {
308
    DeleteExpiredSelfRegs();
316
    DeleteExpiredSelfRegs();
309
}
317
}
310
- 

Return to bug 21336