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

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

Return to bug 21214