Bugzilla – Attachment 141966 Details for
Bug 27265
process_message_queue.pl cron should be able to take multiple types as a parameter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27265: Enable message queue cron to accept multiple codes and types
Bug-27265-Enable-message-queue-cron-to-accept-mult.patch (text/plain), 5.15 KB, created by
Marcel de Rooy
on 2022-10-17 13:10:10 UTC
(
hide
)
Description:
Bug 27265: Enable message queue cron to accept multiple codes and types
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-10-17 13:10:10 UTC
Size:
5.15 KB
patch
obsolete
>From 154a79b82340570c51a71f460514bff231bce055 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 18 Dec 2020 08:45:06 -0500 >Subject: [PATCH] Bug 27265: Enable message queue cron to accept multiple codes > and types >Content-Type: text/plain; charset=utf-8 > >It would be nice to be able to combine several types in a single run, >but exclude others, without having to have multiple cron lines > >Test Plan: >1) Apply this patch >2) Run process_message_queue.pl with a single -c parameter >3) Note behavior is unchanged >4) Run process_message_queue.pl with multiple -c parameters >5) Note all the codes specified are processed >6) Repeat 2-5 with -t for type limits > >Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Letters.pm | 18 ++++++++++++++---- > misc/cronjobs/process_message_queue.pl | 20 ++++++++++---------- > 2 files changed, 24 insertions(+), 14 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 95dfdd0093..71cbd1d4d1 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1232,8 +1232,10 @@ sub _add_attachments { > This function's parameter hash reference takes the following > optional named parameters: > message_transport_type: method of message sending (e.g. email, sms, etc.) >+ Can be a single string, or an arrayref of strings > borrowernumber : who the message is to be sent > letter_code : type of message being sent (e.g. PASSWORD_RESET) >+ Can be a single string, or an arrayref of strings > message_id : the message_id of the message. In that case the sub will return only 1 result > limit : maximum number of messages to send > >@@ -1264,12 +1266,20 @@ sub _get_unsent_messages { > push @query_params, $params->{'borrowernumber'}; > } > if ( $params->{'letter_code'} ) { >- $statement .= ' AND mq.letter_code = ? '; >- push @query_params, $params->{'letter_code'}; >+ my @letter_codes = ref $params->{'letter_code'} eq "ARRAY" ? @{$params->{'letter_code'}} : $params->{'letter_code'}; >+ if ( @letter_codes ) { >+ my $q = join( ",", ("?") x @letter_codes ); >+ $statement .= " AND mq.letter_code IN ( $q ) "; >+ push @query_params, @letter_codes; >+ } > } > if ( $params->{'type'} ) { >- $statement .= ' AND message_transport_type = ? '; >- push @query_params, $params->{'type'}; >+ my @types = ref $params->{'type'} eq "ARRAY" ? @{$params->{'type'}} : $params->{'type'}; >+ if ( @types ) { >+ my $q = join( ",", ("?") x @types ); >+ $statement .= " AND message_transport_type IN ( $q ) "; >+ push @query_params, @types; >+ } > } > if ( $params->{message_id} ) { > $statement .= ' AND message_id = ?'; >diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl >index 5abeb80342..1c6758547d 100755 >--- a/misc/cronjobs/process_message_queue.pl >+++ b/misc/cronjobs/process_message_queue.pl >@@ -32,8 +32,8 @@ my $limit = undef; > my $method = 'LOGIN'; > my $help = 0; > my $verbose = 0; >-my $type = q{}; >-my $letter_code; >+my @type; >+my @letter_code; > > my $command_line_options = join(" ",@ARGV); > >@@ -44,8 +44,8 @@ GetOptions( > 'm|method:s' => \$method, > 'h|help|?' => \$help, > 'v|verbose' => \$verbose, >- 't|type:s' => \$type, >- 'c|code:s' => \$letter_code, >+ 't|type:s' => \@type, >+ 'c|code:s' => \@letter_code, > ); > my $usage = << 'ENDUSAGE'; > >@@ -58,8 +58,8 @@ advance_notices.pl script. > This script has the following parameters : > -u --username: username of mail account > -p --password: password of mail account >- -t --type: If supplied, only processes this type of message ( email, sms ) >- -c --code: If supplied, only processes messages with this letter code >+ -t --type: If supplied, only processes this type of message ( email, sms ), repeatable >+ -c --code: If supplied, only processes messages with this letter code, repeatable > -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 >@@ -95,8 +95,8 @@ if ( C4::Context->config("enable_plugins") ) { > { > verbose => $verbose, > limit => $limit, >- type => $type, >- letter_code => $letter_code, >+ type => \@type, >+ letter_code => @letter_code, > } > ); > } >@@ -114,8 +114,8 @@ C4::Letters::SendQueuedMessages( > password => $password, > method => $method, > limit => $limit, >- type => $type, >- letter_code => $letter_code, >+ type => \@type, >+ letter_code => \@letter_code, > } > ); > >-- >2.30.2
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 27265
:
114522
|
114523
|
114525
|
115430
|
121717
|
130476
|
131434
|
138712
|
141129
|
141130
| 141966 |
141967
|
141968