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

Return to bug 24153