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