Bugzilla – Attachment 190996 Details for
Bug 40934
process_message_queue.pl add ability to exclude some letter code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40934: Add --exclude-code option to process_message_queue.pl
2c6ac65.patch (text/plain), 5.24 KB, created by
Martin Renvoize (ashimema)
on 2026-01-07 15:53:15 UTC
(
hide
)
Description:
Bug 40934: Add --exclude-code option to process_message_queue.pl
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-01-07 15:53:15 UTC
Size:
5.24 KB
patch
obsolete
>From 2c6ac65da28b6fa9d1c0e499a74310579233adfd Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Wed, 7 Jan 2026 15:49:32 +0000 >Subject: [PATCH] Bug 40934: Add --exclude-code option to > process_message_queue.pl > >Some libraries want to send digest messages once per day (e.g., at 20:05) >but send all other messages every hour. Currently, this requires listing >almost all letter codes (~85) in the hourly cron job, which is error-prone >and makes it easy to forget notifications at upgrades. > >This patch adds a new --exclude-code (-x) option to process_message_queue.pl >that allows excluding specific letter codes from processing, making it much >easier to configure digest scheduling. > >Changes: >- Added --exclude-code option to process_message_queue.pl (repeatable) >- Modified C4::Letters::SendQueuedMessages to handle exclude_letter_code parameter >- Supports both scalar and array reference formats > >Example usage: > # Send all messages except digests every hour > 00 */1 * * * process_message_queue.pl --exclude-code DUEDGST \ > --exclude-code PREDUEDGST --exclude-code HOLDDGST \ > --exclude-code AUTO_RENEWALS_DGST > > # Send all messages including digests once per day > 05 20 * * * process_message_queue.pl > >Test plan: >1. Apply both patches >2. Run: ktd --shell --run 'prove t/db_dependent/Letters.t' >3. Verify all tests pass (should show 105 tests passing) >4. Create test messages in message_queue with different letter codes: > - Insert messages with codes: DUEDGST, PREDUEDGST, ACQ_NOTIF, HOLD >5. Test single exclusion: > misc/cronjobs/process_message_queue.pl --exclude-code DUEDGST > - Verify DUEDGST messages remain pending > - Verify other messages are processed >6. Test multiple exclusions: > misc/cronjobs/process_message_queue.pl --exclude-code DUEDGST \ > --exclude-code PREDUEDGST > - Verify both digest messages remain pending > - Verify non-digest messages are processed >7. Test combined with --code option (should work together): > misc/cronjobs/process_message_queue.pl --code ACQ_NOTIF \ > --exclude-code DUEDGST > - Verify only ACQ_NOTIF messages processed (DUEDGST excluded anyway) >8. Test help output: > misc/cronjobs/process_message_queue.pl --help > - Verify --exclude-code option is documented >--- > C4/Letters.pm | 7 +++++++ > misc/cronjobs/process_message_queue.pl | 5 +++++ > 2 files changed, 12 insertions(+) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index c2f540c0723..47f87c1f843 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1077,6 +1077,13 @@ sub SendQueuedMessages { > ref( $params->{letter_code} ) > && @{ $params->{letter_code} } ? ( letter_code => $params->{letter_code} ) : (), > !ref( $params->{letter_code} ) && $params->{letter_code} ? ( letter_code => $params->{letter_code} ) : (), >+ >+ # Check for scalar or array in exclude_letter_code >+ ref( $params->{exclude_letter_code} ) >+ && @{ $params->{exclude_letter_code} } ? ( letter_code => { '-not_in' => $params->{exclude_letter_code} } ) : (), >+ !ref( $params->{exclude_letter_code} ) >+ && $params->{exclude_letter_code} ? ( letter_code => { '!=' => $params->{exclude_letter_code} } ) : (), >+ > ref( $params->{type} ) > && @{ $params->{type} } > ? ( message_transport_type => $params->{type} ) >diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl >index 740a2db9913..b60e7fa74c7 100755 >--- a/misc/cronjobs/process_message_queue.pl >+++ b/misc/cronjobs/process_message_queue.pl >@@ -35,6 +35,7 @@ my $verbose = 0; > my $where; > my @type; > my @letter_code; >+my @exclude_letter_code; > my $exit_on_plugin_failure = 0; > > my $command_line_options = join( " ", @ARGV ); >@@ -49,6 +50,7 @@ GetOptions( > 'v|verbose' => \$verbose, > 't|type:s' => \@type, > 'c|code:s' => \@letter_code, >+ 'x|exclude-code:s' => \@exclude_letter_code, > 'w|where:s' => \$where, > 'e|exit-on-plugin-failure' => \$exit_on_plugin_failure, > ); >@@ -65,6 +67,7 @@ This script has the following parameters : > -p --password: password of mail account > -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 >+ -x --exclude-code: If supplied, processes all messages except those 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 >@@ -89,6 +92,7 @@ try { > > # Remove empty elements, see bug 37075 > @letter_code = grep { $_ ne q{} } @letter_code; >+@exclude_letter_code = grep { $_ ne q{} } @exclude_letter_code; > > C4::Letters::SendQueuedMessages( > { >@@ -99,6 +103,7 @@ C4::Letters::SendQueuedMessages( > limit => $limit, > type => \@type, > letter_code => \@letter_code, >+ exclude_letter_code => \@exclude_letter_code, > where => $where, > exit_on_plugin_failure => $exit_on_plugin_failure, > } >-- >2.52.0 >
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 40934
:
190995
|
190996
|
191304
|
191305
|
191306
|
191307