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

(-)a/misc/cronjobs/cleanup_database.pl (-67 / +133 lines)
Lines 53-62 use Koha::PseudonymizedTransactions; Link Here
53
53
54
sub usage {
54
sub usage {
55
    print STDERR <<USAGE;
55
    print STDERR <<USAGE;
56
Usage: $0 [-h|--help] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS]
56
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS]
57
57
58
   -h --help          prints this help message, and exits, ignoring all
58
   -h --help          prints this help message, and exits, ignoring all
59
                      other options
59
                      other options
60
   --confirm          Confirmation flag, the script will be running in dry-run mode is not set.
60
   --sessions         purge the sessions table.  If you use this while users 
61
   --sessions         purge the sessions table.  If you use this while users 
61
                      are logged into Koha, they will have to reconnect.
62
                      are logged into Koha, they will have to reconnect.
62
   --sessdays DAYS    purge only sessions older than DAYS days.
63
   --sessdays DAYS    purge only sessions older than DAYS days.
Lines 107-112 USAGE Link Here
107
}
108
}
108
109
109
my $help;
110
my $help;
111
my $confirm;
110
my $sessions;
112
my $sessions;
111
my $sess_days;
113
my $sess_days;
112
my $verbose;
114
my $verbose;
Lines 138-143 my ( $pPseudoTransactions, $pPseudoTransactionsFrom, $pPseudoTransactionsTo ); Link Here
138
140
139
GetOptions(
141
GetOptions(
140
    'h|help'            => \$help,
142
    'h|help'            => \$help,
143
    'confirm'           => \$confirm,
141
    'sessions'          => \$sessions,
144
    'sessions'          => \$sessions,
142
    'sessdays:i'        => \$sess_days,
145
    'sessdays:i'        => \$sess_days,
143
    'v|verbose'         => \$verbose,
146
    'v|verbose'         => \$verbose,
Lines 221-227 if ($pDebarments && $allDebarments) { Link Here
221
    usage(1);
224
    usage(1);
222
}
225
}
223
226
224
cronlogaction();
227
say "Confirm flag not passed, running in dry-run mode..." unless $confirm;
228
229
cronlogaction() unless $confirm;
225
230
226
my $dbh = C4::Context->dbh();
231
my $dbh = C4::Context->dbh();
227
my $sth;
232
my $sth;
Lines 236-250 if ( $sessions && !$sess_days ) { Link Here
236
        my @count_arr = $sth->fetchrow_array;
241
        my @count_arr = $sth->fetchrow_array;
237
        print "$count_arr[0] entries will be deleted.\n";
242
        print "$count_arr[0] entries will be deleted.\n";
238
    }
243
    }
239
    $sth = $dbh->prepare(q{ TRUNCATE sessions });
244
    if ( $confirm ) {
240
    $sth->execute() or die $dbh->errstr;
245
        $sth = $dbh->prepare(q{ TRUNCATE sessions });
246
        $sth->execute() or die $dbh->errstr;
247
    }
241
    if ($verbose) {
248
    if ($verbose) {
242
        print "Done with session purge.\n";
249
        print "Done with session purge.\n";
243
    }
250
    }
244
}
251
}
245
elsif ( $sessions && $sess_days > 0 ) {
252
elsif ( $sessions && $sess_days > 0 ) {
246
    print "Session purge triggered with days>$sess_days.\n" if $verbose;
253
    print "Session purge triggered with days>$sess_days.\n" if $verbose;
247
    RemoveOldSessions();
254
    RemoveOldSessions() if $confirm;
248
    print "Done with session purge with days>$sess_days.\n" if $verbose;
255
    print "Done with session purge with days>$sess_days.\n" if $verbose;
249
}
256
}
250
257
Lines 258-267 if ($zebraqueue_days) { Link Here
258
            WHERE done=1 AND time < date_sub(curdate(), INTERVAL ? DAY)
265
            WHERE done=1 AND time < date_sub(curdate(), INTERVAL ? DAY)
259
        }
266
        }
260
    );
267
    );
261
    $sth->execute($zebraqueue_days) or die $dbh->errstr;
268
    if ( $confirm ) {
269
        $sth->execute($zebraqueue_days) or die $dbh->errstr;
270
    }
262
    $sth2 = $dbh->prepare(q{ DELETE FROM zebraqueue WHERE id=? });
271
    $sth2 = $dbh->prepare(q{ DELETE FROM zebraqueue WHERE id=? });
263
    while ( my $record = $sth->fetchrow_hashref ) {
272
    while ( my $record = $sth->fetchrow_hashref ) {
264
        $sth2->execute( $record->{id} ) or die $dbh->errstr;
273
        if ( $confirm ) {
274
            $sth2->execute( $record->{id} ) or die $dbh->errstr;
275
        }
265
        $count++;
276
        $count++;
266
    }
277
    }
267
    print "$count records were deleted.\nDone with zebraqueue purge.\n" if $verbose;
278
    print "$count records were deleted.\nDone with zebraqueue purge.\n" if $verbose;
Lines 275-302 if ($mail) { Link Here
275
            WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY)
286
            WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY)
276
        }
287
        }
277
    );
288
    );
278
    $sth->execute($mail) or die $dbh->errstr;
289
    if ( $confirm ) {
279
    $count = $sth->rows;
290
        $sth->execute($mail) or die $dbh->errstr;
280
    $sth->finish;
291
        $count = $sth->rows;
292
    }
281
    print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose;
293
    print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose;
282
}
294
}
283
295
284
if ($purge_merged) {
296
if ($purge_merged) {
285
    print "Purging completed entries from need_merge_authorities.\n" if $verbose;
297
    print "Purging completed entries from need_merge_authorities.\n" if $verbose;
286
    $sth = $dbh->prepare(q{ DELETE FROM need_merge_authorities WHERE done=1 });
298
    if ( $confirm ) {
287
    $sth->execute() or die $dbh->errstr;
299
        $sth = $dbh->prepare(q{ DELETE FROM need_merge_authorities WHERE done=1 });
300
        $sth->execute() or die $dbh->errstr;
301
    }
288
    print "Done with purging need_merge_authorities.\n" if $verbose;
302
    print "Done with purging need_merge_authorities.\n" if $verbose;
289
}
303
}
290
304
291
if ($pImport) {
305
if ($pImport) {
292
    print "Purging records from import tables.\n" if $verbose;
306
    print "Purging records from import tables.\n" if $verbose;
293
    PurgeImportTables();
307
    PurgeImportTables() if $confirm;
294
    print "Done with purging import tables.\n" if $verbose;
308
    print "Done with purging import tables.\n" if $verbose;
295
}
309
}
296
310
297
if ($pZ3950) {
311
if ($pZ3950) {
298
    print "Purging Z39.50 records from import tables.\n" if $verbose;
312
    print "Purging Z39.50 records from import tables.\n" if $verbose;
299
    PurgeZ3950();
313
    PurgeZ3950() if $confirm;
300
    print "Done with purging Z39.50 records from import tables.\n" if $verbose;
314
    print "Done with purging Z39.50 records from import tables.\n" if $verbose;
301
}
315
}
302
316
Lines 308-326 if ($pLogs) { Link Here
308
            WHERE timestamp < date_sub(curdate(), INTERVAL ? DAY)
322
            WHERE timestamp < date_sub(curdate(), INTERVAL ? DAY)
309
        }
323
        }
310
    );
324
    );
311
    $sth->execute($pLogs) or die $dbh->errstr;
325
    if ( $confirm ) {
326
        $sth->execute($pLogs) or die $dbh->errstr;
327
    }
312
    print "Done with purging action_logs.\n" if $verbose;
328
    print "Done with purging action_logs.\n" if $verbose;
313
}
329
}
314
330
315
if ($fees_days) {
331
if ($fees_days) {
316
    print "Purging records from accountlines.\n" if $verbose;
332
    print "Purging records from accountlines.\n" if $verbose;
317
    purge_zero_balance_fees( $fees_days );
333
    purge_zero_balance_fees( $fees_days ) if $confirm;
318
    print "Done purging records from accountlines.\n" if $verbose;
334
    print "Done purging records from accountlines.\n" if $verbose;
319
}
335
}
320
336
321
if ($pSearchhistory) {
337
if ($pSearchhistory) {
322
    print "Purging records older than $pSearchhistory from search_history.\n" if $verbose;
338
    print "Purging records older than $pSearchhistory from search_history.\n" if $verbose;
323
    C4::Search::History::delete({ interval => $pSearchhistory });
339
    C4::Search::History::delete({ interval => $pSearchhistory }) if $confirm;
324
    print "Done with purging search_history.\n" if $verbose;
340
    print "Done with purging search_history.\n" if $verbose;
325
}
341
}
326
342
Lines 333-474 if ($pListShareInvites) { Link Here
333
            AND (sharedate + INTERVAL ? DAY) < NOW()
349
            AND (sharedate + INTERVAL ? DAY) < NOW()
334
        }
350
        }
335
    );
351
    );
336
    $sth->execute($pListShareInvites);
352
    if ( $confirm ) {
353
        $sth->execute($pListShareInvites);
354
    }
337
    print "Done with purging unaccepted list share invites.\n" if $verbose;
355
    print "Done with purging unaccepted list share invites.\n" if $verbose;
338
}
356
}
339
357
340
if ($pDebarments) {
358
if ($pDebarments) {
341
    print "Expired patrons restrictions purge triggered for $pDebarments days.\n" if $verbose;
359
    print "Expired patrons restrictions purge triggered for $pDebarments days.\n" if $verbose;
342
    $count = PurgeDebarments($pDebarments);
360
    $count = PurgeDebarments($pDebarments, $confirm);
343
    print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose;
361
    print "$count restrictions were deleted.\nDone with restrictions purge.\n" if $verbose;
344
}
362
}
345
363
346
if($allDebarments) {
364
if($allDebarments) {
347
    print "All expired patrons restrictions purge triggered.\n" if $verbose;
365
    print "All expired patrons restrictions purge triggered.\n" if $verbose;
348
    $count = PurgeDebarments(0);
366
    $count = PurgeDebarments(0, $confirm);
349
    print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose;
367
    print "$count restrictions were deleted.\nDone with all restrictions purge.\n" if $verbose;
350
}
368
}
351
369
352
# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference
370
# Handle unsubscribe requests from GDPR consent form, depends on UnsubscribeReflectionDelay preference
353
my $unsubscribed_patrons = Koha::Patrons->search_unsubscribed;
371
my $unsubscribed_patrons = Koha::Patrons->search_unsubscribed;
354
$count = $unsubscribed_patrons->count;
372
$count = $unsubscribed_patrons->count;
355
$unsubscribed_patrons->lock( { expire => 1, remove => 1 } );
373
$unsubscribed_patrons->lock( { expire => 1, remove => 1 } ) if $confirm;
356
say sprintf "Locked %d patrons", $count if $verbose;
374
say sprintf "Locked %d patrons", $count if $verbose;
357
375
358
# Anonymize patron data, depending on PatronAnonymizeDelay
376
# Anonymize patron data, depending on PatronAnonymizeDelay
359
my $anonymize_candidates = Koha::Patrons->search_anonymize_candidates( { locked => 1 } );
377
my $anonymize_candidates = Koha::Patrons->search_anonymize_candidates( { locked => 1 } );
360
$count = $anonymize_candidates->count;
378
$count = $anonymize_candidates->count;
361
$anonymize_candidates->anonymize;
379
$anonymize_candidates->anonymize if $confirm;
362
say sprintf "Anonymized %s patrons", $count if $verbose;
380
say sprintf "Anonymized %s patrons", $count if $verbose;
363
381
364
# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered
382
# Remove patron data, depending on PatronRemovalDelay (will raise an exception if problem encountered
365
my $anonymized_patrons = Koha::Patrons->search_anonymized;
383
my $anonymized_patrons = Koha::Patrons->search_anonymized;
366
$count = $anonymized_patrons->count;
384
$count = $anonymized_patrons->count;
367
$anonymized_patrons->delete( { move => 1 } );
385
if ( $confirm ) {
368
if ($@) {
386
    $anonymized_patrons->delete( { move => 1 } );
369
    warn $@;
387
    if ($@) {
370
}
388
        warn $@;
371
elsif ($verbose) {
389
    }
390
    elsif ($verbose) {
391
        say sprintf "Deleted %d patrons", $count;
392
    }
393
} else {
372
    say sprintf "Deleted %d patrons", $count;
394
    say sprintf "Deleted %d patrons", $count;
373
}
395
}
374
396
397
# FIXME The output for dry-run mode needs to be improved
398
# But non trivial changes to C4::Members need to be done before.
375
if( $pExpSelfReg ) {
399
if( $pExpSelfReg ) {
376
    DeleteExpiredSelfRegs();
400
    if ( $confirm ) {
401
        DeleteExpiredSelfRegs();
402
    } elsif ( $verbose ) {
403
        say "self-registered borrowers may be deleted";
404
    }
377
}
405
}
378
if( $pUnvSelfReg ) {
406
if( $pUnvSelfReg ) {
379
    DeleteUnverifiedSelfRegs( $pUnvSelfReg );
407
    if ( $confirm ) {
408
        DeleteUnverifiedSelfRegs( $pUnvSelfReg );
409
    } elsif ( $verbose ) {
410
        say "unverified self-registrations may be deleted";
411
    }
380
}
412
}
381
413
382
if ($special_holidays_days) {
414
if ($special_holidays_days) {
383
    DeleteSpecialHolidays( abs($special_holidays_days) );
415
    if ( $confirm ) {
416
        DeleteSpecialHolidays( abs($special_holidays_days) );
417
    } elsif ( $verbose ) {
418
        say "self-registered borrowers may be deleted";
419
    }
384
}
420
}
385
421
386
if( $temp_uploads ) {
422
if( $temp_uploads ) {
387
    # Delete temporary uploads, governed by a pref (unless you override)
423
    # Delete temporary uploads, governed by a pref (unless you override)
388
    print "Purging temporary uploads.\n" if $verbose;
424
    print "Purging temporary uploads.\n" if $verbose;
389
    Koha::UploadedFiles->delete_temporary({
425
    if ( $confirm ) {
390
        defined($temp_uploads_days)
426
        Koha::UploadedFiles->delete_temporary({
391
            ? ( override_pref => $temp_uploads_days )
427
            defined($temp_uploads_days)
392
            : ()
428
                ? ( override_pref => $temp_uploads_days )
393
    });
429
                : ()
430
        });
431
    }
394
    print "Done purging temporary uploads.\n" if $verbose;
432
    print "Done purging temporary uploads.\n" if $verbose;
395
}
433
}
396
434
397
if( defined $uploads_missing ) {
435
if( defined $uploads_missing ) {
398
    print "Looking for missing uploads\n" if $verbose;
436
    print "Looking for missing uploads\n" if $verbose;
399
    my $keep = $uploads_missing == 1 ? 0 : 1;
437
    if ( $confirm ) {
400
    my $count = Koha::UploadedFiles->delete_missing({ keep_record => $keep });
438
        my $keep = $uploads_missing == 1 ? 0 : 1;
401
    if( $keep ) {
439
        my $count = Koha::UploadedFiles->delete_missing({ keep_record => $keep });
402
        print "Counted $count missing uploaded files\n";
440
        if( $keep ) {
441
            print "Counted $count missing uploaded files\n";
442
        } else {
443
            print "Removed $count records for missing uploads\n";
444
        }
403
    } else {
445
    } else {
404
        print "Removed $count records for missing uploads\n";
446
        # FIXME need to create a filter_by_missing method (then call ->delete) instead of delete_missing
447
        say "Dry-run mode cannot guess how many uploads would have been deleted";
405
    }
448
    }
406
}
449
}
407
450
408
if ($oauth_tokens) {
451
if ($oauth_tokens) {
409
    require Koha::OAuthAccessTokens;
452
    require Koha::OAuthAccessTokens;
410
453
411
    my $count = int Koha::OAuthAccessTokens->search({ expires => { '<=', time } })->delete;
454
    my $tokens = Koha::OAuthAccessTokens->search({ expires => { '<=', time } });
412
    say "Removed $count expired OAuth2 tokens" if $verbose;
455
    my $count = $tokens->count;
456
    $tokens->delete if $confirm;
457
    say sprintf "Removed %s expired OAuth2 tokens", $count if $verbose;
413
}
458
}
414
459
415
if ($pStatistics) {
460
if ($pStatistics) {
416
    print "Purging statistics older than $pStatistics days.\n" if $verbose;
461
    print "Purging statistics older than $pStatistics days.\n" if $verbose;
417
    Koha::Statistics->filter_by_last_update(
462
    my $statistics = Koha::Statistics->filter_by_last_update(
418
        { timestamp_column_name => 'datetime', days => $pStatistics } )->delete;
463
        { timestamp_column_name => 'datetime', days => $pStatistics } );
419
    print "Done with purging statistics.\n" if $verbose;
464
    my $count = $statistics->count;
465
    $statistics->delete if $confirm;
466
    say sprintf "Done with purging %s statistics.", $count if $verbose;
420
}
467
}
421
468
422
if ($pDeletedCatalog) {
469
if ($pDeletedCatalog) {
423
    print "Purging deleted catalog older than $pDeletedCatalog days.\n" if $verbose;
470
    print "Purging deleted catalog older than $pDeletedCatalog days.\n"
424
    Koha::Old::Items      ->filter_by_last_update( { days => $pDeletedCatalog } )->delete;
471
      if $verbose;
425
    Koha::Old::Biblioitems->filter_by_last_update( { days => $pDeletedCatalog } )->delete;
472
    my $old_items = Koha::Old::Items->filter_by_last_update( { days => $pDeletedCatalog } );
426
    Koha::Old::Biblios    ->filter_by_last_update( { days => $pDeletedCatalog } )->delete;
473
    my $old_biblioitems = Koha::Old::Biblioitems->filter_by_last_update( { days => $pDeletedCatalog } );
427
    print "Done with purging deleted catalog.\n" if $verbose;
474
    my $old_biblios = Koha::Old::Biblios->filter_by_last_update( { days => $pDeletedCatalog } );
475
    my ( $c_i, $c_bi, $c_b ) =
476
      ( $old_items->count, $old_biblioitems->count, $old_biblios->count );
477
    if ($confirm) {
478
        $old_items->delete;
479
        $old_biblioitems->delete;
480
        $old_biblios->delete;
481
    }
482
    say sprintf
483
        "Done with purging deleted catalog (%d items, %d biblioitems, %d biblios).",
484
      $c_i, $c_bi, $c_b
485
      if $verbose;
428
}
486
}
429
487
430
if ($pDeletedPatrons) {
488
if ($pDeletedPatrons) {
431
    print "Purging deleted patrons older than $pDeletedPatrons days.\n" if $verbose;
489
    print "Purging deleted patrons older than $pDeletedPatrons days.\n" if $verbose;
432
    Koha::Old::Patrons->filter_by_last_update(
490
    my $old_patrons = Koha::Old::Patrons->filter_by_last_update(
433
        { timestamp_column_name => 'updated_on', days => $pDeletedPatrons } )
491
        { timestamp_column_name => 'updated_on', days => $pDeletedPatrons } );
434
      ->delete;
492
    my $count = $old_patrons->count;
435
    print "Done with purging deleted patrons.\n" if $verbose;
493
    $old_patrons->delete if $confirm;
494
    say sprintf "Done with purging %d deleted patrons.", $count if $verbose;
436
}
495
}
437
496
438
if ($pOldIssues) {
497
if ($pOldIssues) {
439
    print "Purging old checkouts older than $pOldIssues days.\n" if $verbose;
498
    print "Purging old checkouts older than $pOldIssues days.\n" if $verbose;
440
    Koha::Old::Checkouts->filter_by_last_update( { days => $pOldIssues } )->delete;
499
    my $old_checkouts = Koha::Old::Checkouts->filter_by_last_update( { days => $pOldIssues } );
441
    print "Done with purging old issues.\n" if $verbose;
500
    my $count = $old_checkouts->count;
501
    $old_checkouts->delete if $confirm;
502
    say sprintf "Done with purging %d old checkouts.", $count if $verbose;
442
}
503
}
443
504
444
if ($pOldReserves) {
505
if ($pOldReserves) {
445
    print "Purging old reserves older than $pOldReserves days.\n" if $verbose;
506
    print "Purging old reserves older than $pOldReserves days.\n" if $verbose;
446
    Koha::Old::Holds->filter_by_last_update( { days => $pOldReserves } )->delete;
507
    my $old_reserves = Koha::Old::Holds->filter_by_last_update( { days => $pOldReserves } );
447
    print "Done with purging old reserves.\n" if $verbose;
508
    my $count = $old_reserves->count;
509
    $old_reserves->delete if $verbose;
510
    say sprintf "Done with purging %d old reserves.", $count if $verbose;
448
}
511
}
449
512
450
if ($pTransfers) {
513
if ($pTransfers) {
451
    print "Purging arrived item transfers older than $pTransfers days.\n" if $verbose;
514
    print "Purging arrived item transfers older than $pTransfers days.\n" if $verbose;
452
    Koha::Item::Transfers->filter_by_last_update(
515
    my $transfers = Koha::Item::Transfers->filter_by_last_update(
453
        {
516
        {
454
            timestamp_column_name => 'datearrived',
517
            timestamp_column_name => 'datearrived',
455
            days => $pTransfers,
518
            days => $pTransfers,
456
        }
519
        }
457
    )->delete;
520
    );
458
    print "Done with purging transfers.\n" if $verbose;
521
    my $count = $transfers->count;
522
    $transfers->delete if $verbose;
523
    say sprintf "Done with purging %d transfers.", $count if $verbose;
459
}
524
}
460
525
461
if (defined $pPseudoTransactions or $pPseudoTransactionsFrom or $pPseudoTransactionsTo ) {
526
if (defined $pPseudoTransactions or $pPseudoTransactionsFrom or $pPseudoTransactionsTo ) {
462
    print "Purging pseudonymized transactions\n" if $verbose;
527
    print "Purging pseudonymized transactions\n" if $verbose;
463
    Koha::PseudonymizedTransactions->filter_by_last_update(
528
    my $anonymized_transactions = Koha::PseudonymizedTransactions->filter_by_last_update(
464
        {
529
        {
465
            timestamp_column_name => 'datetime',
530
            timestamp_column_name => 'datetime',
466
            ( defined $pPseudoTransactions  ? ( days => $pPseudoTransactions     ) : () ),
531
            ( defined $pPseudoTransactions  ? ( days => $pPseudoTransactions     ) : () ),
467
            ( $pPseudoTransactionsFrom      ? ( from => $pPseudoTransactionsFrom ) : () ),
532
            ( $pPseudoTransactionsFrom      ? ( from => $pPseudoTransactionsFrom ) : () ),
468
            ( $pPseudoTransactionsTo        ? ( to   => $pPseudoTransactionsTo   ) : () ),
533
            ( $pPseudoTransactionsTo        ? ( to   => $pPseudoTransactionsTo   ) : () ),
469
        }
534
        }
470
    )->delete;
535
    );
471
    print "Done with purging pseudonymized transactions.\n" if $verbose;
536
    my $count = $anonymized_transactions->count;
537
    $anonymized_transactions->delete if $confirm;
538
    say sprintf "Done with purging %d pseudonymized transactions.", $count if $verbose;
472
}
539
}
473
540
474
exit(0);
541
exit(0);
Lines 542-548 sub PurgeZ3950 { Link Here
542
609
543
sub PurgeDebarments {
610
sub PurgeDebarments {
544
    require Koha::Patron::Debarments;
611
    require Koha::Patron::Debarments;
545
    my $days = shift;
612
    my ( $days, $doit ) = @_;
546
    $count = 0;
613
    $count = 0;
547
    $sth   = $dbh->prepare(
614
    $sth   = $dbh->prepare(
548
        q{
615
        q{
Lines 553-559 sub PurgeDebarments { Link Here
553
    );
620
    );
554
    $sth->execute($days) or die $dbh->errstr;
621
    $sth->execute($days) or die $dbh->errstr;
555
    while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) {
622
    while ( my ($borrower_debarment_id) = $sth->fetchrow_array ) {
556
        Koha::Patron::Debarments::DelDebarment($borrower_debarment_id);
623
        Koha::Patron::Debarments::DelDebarment($borrower_debarment_id) if $doit;
557
        $count++;
624
        $count++;
558
    }
625
    }
559
    return $count;
626
    return $count;
560
- 

Return to bug 24153