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

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

Return to bug 24153