Bugzilla – Attachment 148625 Details for
Bug 21214
cleanup_database.pl --mail should let admin choose which letter codes to keep
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21214: (fix) Rebuild the sql query
Bug-21214-fix-Rebuild-the-sql-query.patch (text/plain), 2.42 KB, created by
Hammat wele
on 2023-03-23 22:31:19 UTC
(
hide
)
Description:
Bug 21214: (fix) Rebuild the sql query
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2023-03-23 22:31:19 UTC
Size:
2.42 KB
patch
obsolete
>From 1426a402d30e762c90c0a7e103c0edd9f882ff0b Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Thu, 23 Mar 2023 22:30:52 +0000 >Subject: [PATCH] Bug 21214: (fix) Rebuild the sql query > >--- > misc/cronjobs/cleanup_database.pl | 36 +++++++++++++++---------------- > 1 file changed, 18 insertions(+), 18 deletions(-) > >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index a4cf1ec2b1..90f90ae4ad 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -286,11 +286,6 @@ say "Confirm flag not passed, running in dry-run mode..." unless $confirm; > > cronlogaction({ info => $command_line_options }); > >-if (!$mail && $letter_codes) { >- print "You should not specify --keep-lc if you're not cleaning emails.\n\n"; >- usage(1); >-} >- > my $dbh = C4::Context->dbh(); > my $sth; > my $sth2; >@@ -345,21 +340,26 @@ if ($mail) { > my $count = 0; > print "Mail queue purge triggered for $mail days.\n" if $verbose; > print "Not deleting emails of type $letter_codes.\n" if ($verbose && $letter_codes); >- my (@codes, $quoted_codes); >+ my $query = q{ >+ DELETE FROM message_queue >+ WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) >+ }; >+ my @bind_params = ($mail); > if ($letter_codes) { > $letter_codes =~ s/ //g; >- @codes = map { "$_" } split(',', $letter_codes); >- $quoted_codes = join ",", ("?") x @codes; >- } >- >- $sth = $dbh->prepare(" >- DELETE FROM message_queue >- WHERE time_queued < date_sub(curdate(), INTERVAL ? DAY) >- AND letter_code NOT IN ( $quoted_codes )"); >- $sth->execute($mail, @codes) or die $dbh->errstr; >- $count = $sth->rows; >- $sth->finish; >- print "$count messages were deleted from the mail queue.\nDone with message_queue purge.\n" if $verbose; >+ my @codes = map { "$_" } split(',', $letter_codes); >+ $query .= " AND letter_code NOT IN ( ".(join ",", ("?") x @codes)." )"; >+ push @bind_params, @codes; >+ } >+ $sth = $dbh->prepare($query); >+ if ( $confirm ) { >+ $sth->execute(@bind_params) or die $dbh->errstr; >+ $count = $sth->rows; >+ } >+ if ( $verbose ) { >+ say $confirm ? "$count messages were deleted from the mail queue." : "Message from message_queue would have been deleted"; >+ say "Done with message_queue purge."; >+ } > } > > if ($purge_merged) { >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21214
:
77756
|
77762
|
112992
|
112993
|
112994
|
113002
|
113008
|
113009
|
148622
|
148623
|
148624
|
148625
|
158679
|
158680
|
158681
|
162064