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

(-)a/misc/cronjobs/cleanup_database.pl (-11 / +10 lines)
Lines 345-362 if ($mail) { Link Here
345
    my $count = 0;
345
    my $count = 0;
346
    print "Mail queue purge triggered for $mail days.\n" if $verbose;
346
    print "Mail queue purge triggered for $mail days.\n" if $verbose;
347
    print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes);
347
    print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes);
348
    my $query = q{
348
    my (@codes, $quoted_codes);
349
        DELETE FROM message_queue
350
        WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY)
351
          AND letter_code NOT IN ( ? )
352
    };
353
    my $quoted_codes = '';
354
    if ($letter_codes) {
349
    if ($letter_codes) {
355
        my @codes = map { "'$_'" } split(',', $letter_codes);
350
        $letter_codes =~ s/ //g;
356
        my $quoted_codes = join(',', @codes);
351
        @codes = map { "$_" } split(',', $letter_codes);
352
        $quoted_codes = join ",", ("?") x @codes;
357
    }
353
    }
358
    $sth = $dbh->prepare($query);
354
359
    $sth->execute($mail, $quoted_codes) or die $dbh->errstr;
355
    $sth = $dbh->prepare("
356
        DELETE FROM message_queue
357
        WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY)
358
          AND letter_code NOT IN ( $quoted_codes )");
359
    $sth->execute($mail, @codes) or die $dbh->errstr;
360
    $count = $sth->rows;
360
    $count = $sth->rows;
361
    $sth->finish;
361
    $sth->finish;
362
    print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose;
362
    print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose;
363
- 

Return to bug 21214