Lines 286-296
say "Confirm flag not passed, running in dry-run mode..." unless $confirm;
Link Here
|
286 |
|
286 |
|
287 |
cronlogaction({ info => $command_line_options }); |
287 |
cronlogaction({ info => $command_line_options }); |
288 |
|
288 |
|
289 |
if (!$mail && $letter_codes) { |
|
|
290 |
print "You should not specify --keep-lc if you're not cleaning emails.\n\n"; |
291 |
usage(1); |
292 |
} |
293 |
|
294 |
my $dbh = C4::Context->dbh(); |
289 |
my $dbh = C4::Context->dbh(); |
295 |
my $sth; |
290 |
my $sth; |
296 |
my $sth2; |
291 |
my $sth2; |
Lines 345-365
if ($mail) {
Link Here
|
345 |
my $count = 0; |
340 |
my $count = 0; |
346 |
print "Mail queue purge triggered for $mail days.\n" if $verbose; |
341 |
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); |
342 |
print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes); |
348 |
my (@codes, $quoted_codes); |
343 |
my $query = q{ |
|
|
344 |
DELETE FROM message_queue |
345 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
346 |
}; |
347 |
my @bind_params = ($mail); |
349 |
if ($letter_codes) { |
348 |
if ($letter_codes) { |
350 |
$letter_codes =~ s/ //g; |
349 |
$letter_codes =~ s/ //g; |
351 |
@codes = map { "$_" } split(',', $letter_codes); |
350 |
my @codes = map { "$_" } split(',', $letter_codes); |
352 |
$quoted_codes = join ",", ("?") x @codes; |
351 |
$query .= " AND letter_code NOT IN ( ".(join ",", ("?") x @codes)." )"; |
353 |
} |
352 |
push @bind_params, @codes; |
354 |
|
353 |
} |
355 |
$sth = $dbh->prepare(" |
354 |
$sth = $dbh->prepare($query); |
356 |
DELETE FROM message_queue |
355 |
if ( $confirm ) { |
357 |
WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) |
356 |
$sth->execute(@bind_params) or die $dbh->errstr; |
358 |
AND letter_code NOT IN ( $quoted_codes )"); |
357 |
$count = $sth->rows; |
359 |
$sth->execute($mail, @codes) or die $dbh->errstr; |
358 |
} |
360 |
$count = $sth->rows; |
359 |
if ( $verbose ) { |
361 |
$sth->finish; |
360 |
say $confirm ? "$count messages were deleted from the mail queue." : "Message from message_queue would have been deleted"; |
362 |
print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; |
361 |
say "Done with message_queue purge."; |
|
|
362 |
} |
363 |
} |
363 |
} |
364 |
|
364 |
|
365 |
if ($purge_merged) { |
365 |
if ($purge_merged) { |
366 |
- |
|
|