Bugzilla – Attachment 79719 Details for
Bug 15529
Process Message Queue may send duplicate emails if process is launched twice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15529: Followup to send without more libraries
Bug-15529-Followup-to-send-without-more-libraries.patch (text/plain), 4.22 KB, created by
Mark Tompsett
on 2018-10-01 14:32:19 UTC
(
hide
)
Description:
Bug 15529: Followup to send without more libraries
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2018-10-01 14:32:19 UTC
Size:
4.22 KB
patch
obsolete
>From 0446b121c5e2254f6dc7c1e9a149fe090d55d0e8 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Mon, 1 Oct 2018 13:51:30 +0000 >Subject: [PATCH] Bug 15529: Followup to send without more libraries > >This uses the letter_code parameter to limit the current >duplicate run of the process_message_queue.pl script to >just this one message. > >We don't care about receiving duplicate warning messages >as much as we care about sending patrons duplicate messages. >--- > misc/cronjobs/process_message_queue.pl | 63 ++++++++++++++++++---------------- > 1 file changed, 34 insertions(+), 29 deletions(-) > >diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl >index b15b595..2f648d3 100755 >--- a/misc/cronjobs/process_message_queue.pl >+++ b/misc/cronjobs/process_message_queue.pl >@@ -38,11 +38,6 @@ my $help = 0; > my $verbose = 0; > my $type = q{}; > >-use MIME::Lite; >-use Mail::Sendmail; >-use Encode; >-use Net::SMTP; >- > use Fcntl ':flock'; > > >@@ -76,46 +71,56 @@ This script has the following parameters : > -l --limit: The maximum number of messages to process for this run > -m --method: authentication method required by SMTP server (See perldoc Sendmail.pm for supported authentication types.) > -h --help: this message >- -v --verbose: provides verbose output to STDOUT, if verbose is set then emails will be sent upon duplicate execution of this cronjob >+ -v --verbose: provides verbose output to STDOUT. >+ Also useful for testing duplicate runs. Make sure the KohaAdminEmail preference is set. > ENDUSAGE > > die $usage if $help; > > cronlogaction(); > >-print "start of program\n"; >+if ($verbose) { print "start of program\n"; } > my $logdir = C4::Context->config('logdir'); > > chomp $logdir; > my $instancemessagequeuefile = $logdir . "/messagequeue.lock"; > open(FOO, ">> $instancemessagequeuefile") or die "Cannot write to $instancemessagequeuefile: $!"; > >-print "Getting the lock\n"; >+my $letter_code = ''; >+if ($verbose) { print "Getting the lock\n"; } > unless (flock ( FOO, LOCK_EX|LOCK_NB )) { > >- print "$0 is already running. Exiting.\n"; >+ print STDERR "$0 is already running!\n"; > #If verbose is set send email to inform administrator another process_message_queue.pl cron was attempted to run whilst previous execution of the file is taking place. > # Configure accordingly > >- if ($verbose) { >- MIME::Lite->send( 'smtp', ''); >- my $email = MIME::Lite->new( >- To => ' ', >- From => ' ', >- Type => 'TEXT', >- Subject => 'process_message_queue.pl cron is already running', >- Data => 'process_message_queue.pl cron is already running', >- ); >- >- $email->attach( >- Type => 'Text', >- Data => 'process_message_queue.pl cron is already running', >- ); >- $email->send(); >- exit(1); >- } >+ C4::Letters::EnqueueLetter( >+ 0, #borrowernumber >+ 'process_message_queue.pl cron is already running', #subject >+ 'process_message_queue.pl cron is already running', #content >+ '', #metadata >+ 'DUPLICATE_PROCESS_MESSAGE_QUEUE', #letter_code >+ 'email', #message_transport_type >+ 'pending', #status >+ C4::Context->preference('KohaAdminEmail'), #to_address >+ C4::Context->preference('KohaAdminEmail'), #from_address >+ 'text' #content_type >+ ); >+ $letter_code = 'DUPLICATE_PROCESS_MESSAGE_QUEUE'; > } > >-C4::Letters::SendQueuedMessages( { verbose => $verbose, username => $username, password => $password, method => $method } ); >-sleep(15); >-print "End of process_message_queue.pl cron process"; >+C4::Letters::SendQueuedMessages( >+ { >+ verbose => $verbose, >+ username => $username, >+ password => $password, >+ method => $method, >+ limit => $limit, >+ type => $type, >+ letter_code => $letter_code, >+ } >+); >+if ($verbose) { >+ sleep(15); >+ print "End of process_message_queue.pl cron process"; >+} >-- >2.1.4
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 15529
:
78205
|
78210
|
78211
|
78212
|
78582
|
78918
|
79649
|
79719
|
79726
|
79910
|
79911
|
79912
|
79913
|
80256