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

(-)a/misc/cronjobs/cleanup_database.pl (-11 / +10 lines)
Lines 294-311 if ($mail) { Link Here
294
    my $count = 0;
294
    my $count = 0;
295
    print "Mail queue purge triggered for $mail days.\n" if $verbose;
295
    print "Mail queue purge triggered for $mail days.\n" if $verbose;
296
    print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes);
296
    print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes);
297
    my $query = q{
297
    my (@codes, $quoted_codes);
298
        DELETE FROM message_queue
299
        WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY)
300
          AND letter_code NOT IN ( ? )
301
    };
302
    my $quoted_codes = '';
303
    if ($letter_codes) {
298
    if ($letter_codes) {
304
        my @codes = map { "'$_'" } split(',', $letter_codes);
299
        $letter_codes =~ s/ //g;
305
        my $quoted_codes = join(',', @codes);
300
        @codes = map { "$_" } split(',', $letter_codes);
301
        $quoted_codes = join ",", ("?") x @codes;
306
    }
302
    }
307
    $sth = $dbh->prepare($query);
303
        
308
    $sth->execute($mail, $quoted_codes) or die $dbh->errstr;
304
    $sth = $dbh->prepare("
305
        DELETE FROM message_queue
306
        WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY)
307
          AND letter_code NOT IN ( $quoted_codes )");
308
    $sth->execute($mail, @codes) or die $dbh->errstr;
309
    $count = $sth->rows;
309
    $count = $sth->rows;
310
    $sth->finish;
310
    $sth->finish;
311
    print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose;
311
    print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose;
312
- 

Return to bug 21214