Koha-clms/C4
Martin Renvoize 3430793f07
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

Sponsored-by: OpenFifth <https://openfifth.co.uk/>
Signed-off-by: Marion Durand <marion.durand@biblibre.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
2026-09-21 11:56:45 +00:00
..
AuthoritiesMarc Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Barcodes Bug 42221: Fix EAN-13 autoBarcode not incrementing 2026-04-16 15:54:09 -06:00
ClassSortRoutine Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ClassSplitRoutine Bug 30233: (follow-up) Fix POD formatting codes in _apply_substitution 2026-08-11 12:39:32 +00:00
Creators Bug 42764: Fix spelling errors across the codebase 2026-06-03 16:09:04 +00:00
External Bug 41318: Rename AmazonLocale to AmazonLocaleTld 2026-09-10 14:25:34 +00:00
Form Bug 28308: Remove 0 from "days in advance" for "Advance notice" 2026-01-30 10:54:02 -07:00
Heading Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ILSDI Bug 40622: Add missing interface parameter 2025-10-06 09:15:27 -06:00
Installer Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Labels Bug 40473: Use better algorithm for calculating Code39 barcode length 2025-09-26 10:36:41 -06:00
Linker Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Members Bug 28308: Remove 0 from "days in advance" for "Advance notice" 2026-01-30 10:54:02 -07:00
OAI Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Output Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Patroncards Bug 40680: Fix C4/Patroncards/Patroncard.pm 2025-12-01 08:33:57 -07:00
Reports Bug 16631: Institute library limits 2026-07-28 14:32:25 +00:00
SIP Bug 39829: (QA follow-up) Pass server through for the title field 2026-09-03 10:56:53 +00:00
Search Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Serials Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Utils/DataTables Bug 42764: Fix spelling errors across the codebase 2026-06-03 16:09:04 +00:00
Accounts.pm Bug 42396: Remove C4::Stats::UpdateStats and delete module 2026-07-27 15:53:22 +00:00
Acquisition.pm Bug 39959: Add a total column to the invoices table 2026-08-25 08:56:32 +00:00
Auth.pm Bug 42066: Prevent 403 after an expired OPAC session 2026-07-16 17:04:59 +00:00
Auth_cas_servers.yaml.sample Bug 17065 - Rename C4/Auth_cas_servers.yaml.orig 2016-08-08 13:16:36 +00:00
Auth_with_cas.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
Auth_with_ldap.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
Auth_with_shibboleth.pm Bug 42764: Fix false positives caused by POD letter-code formatting 2026-06-03 16:09:05 +00:00
AuthoritiesMarc.pm Bug 41685: (QA follow-up) Classify MARC21 $w by position 0 2026-06-19 15:39:08 +00:00
Barcodes.pm Bug 18584: Remove trailing spaces in Barcodes.pm 2025-11-18 06:56:42 -07:00
Biblio.pm Bug 35104: (RM follow-up) Restore StripNonXmlChars in TransformHtmlToMarc 2026-08-19 14:34:00 +00:00
Breeding.pm Bug 42321: Improve handling of empty Z3950/SRU search results 2026-06-29 15:39:10 +00:00
Budgets.pm Bug 41742: (follow-up) Add pod to AddBudgetPeriod 2026-09-16 14:42:14 +00:00
Calendar.pm Bug 42310: (QA follow-up) Restore in-memory holiday cache sync in C4::Calendar 2026-09-15 16:14:05 +00:00
Charset.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
Circulation.pm Bug 42385: Remove _GetCircControlBranch 2026-09-21 11:11:32 +00:00
ClassSortRoutine.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
ClassSource.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
ClassSplitRoutine.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
Context.pm Bug 39337: Add is_opac_suppressed helper to C4::Context 2026-08-25 08:56:25 +00:00
Contract.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
CourseReserves.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
Creators.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
HTML5Media.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Heading.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
HoldsQueue.pm Bug 42310: (follow-up) Move Koha::Calendar tree under Koha::Library::Calendar 2026-09-15 16:14:02 +00:00
ImportBatch.pm Bug 39516: (follow-up) Add missing POD for private subroutines 2026-04-29 09:09:23 -06:00
ImportExportFramework.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
InstallAuth.pm Bug 41454: Remove unused dbh calls 2026-04-15 09:14:51 -06:00
Installer.pm Bug 42318: Populate record_sources with system defined values on install 2026-04-15 09:14:45 -06:00
ItemCirculationAlertPreference.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Items.pm Bug 42746: (QA follow-up) Sanitize agefield and substitution field at the sink too 2026-08-11 12:39:38 +00:00
Koha.pm Bug 32748: (QA follow-up) Fix duplicate AV when limited to several libraries at once 2026-09-15 14:45:06 +00:00
Labels.pm Bug 21395: Make perlcritic happy 2020-06-29 12:37:02 +02:00
Languages.pm Bug 42727: Sort using the order from the staff syspref 2026-08-28 16:36:44 +00:00
Letters.pm Bug 40934: Add --exclude-code option to process_message_queue.pl 2026-09-21 11:56:45 +00:00
Linker.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Log.pm Bug 42766: Add logscriptaction() to C4::Log 2026-08-04 10:20:49 +00:00
MarcModificationTemplates.pm Bug 28915: Fix field_exists call in C4::MarcModificationTemplates 2026-06-15 15:24:13 +00:00
Matcher.pm Bug 39516: (follow-up) Add missing POD for private subroutines 2026-04-29 09:09:23 -06:00
Members.pm Bug 42700: Remove dead $flags->{WAITING} code from C4::Members::patronflags 2026-08-18 11:21:24 +00:00
Message.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Output.pm Bug 39337: Add is_opac_suppressed helper to C4::Context 2026-08-25 08:56:25 +00:00
Overdues.pm Bug 42310: (QA follow-up) Clean up stale references to dropped calendar tables 2026-09-15 16:14:15 +00:00
Patroncards.pm Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
Record.pm Bug 41706: "Use of uninitialized value..." warning in C4/Record.pm 2026-08-25 08:56:20 +00:00
Reports.pm Bug 42360: Move separator validation to C4::Context::csv_delimiter 2026-07-13 15:46:31 +00:00
Reserves.pm Bug 42310: (follow-up) Move Koha::Calendar tree under Koha::Library::Calendar 2026-09-15 16:14:02 +00:00
Ris.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
RotatingCollections.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
SMS.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Scheduler.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
Scrubber.pm Bug 40659: Change Scrubber profile name to opac_virtual_card 2026-04-23 16:04:11 -06:00
Search.pm Bug 31391: Implement UseRecalls choices in modules 2026-09-14 14:15:48 +00:00
Serials.pm Bug 41330: Escape braces in serials number management 2026-03-09 17:06:50 -06:00
Service.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
ShelfBrowser.pm Bug 42567: Remove C4::Koha::GetNormalizedEAN in favor of MetadataExtractor 2026-08-20 15:34:10 +00:00
SocialData.pm Bug 42764: Fix spelling errors across the codebase 2026-06-03 16:09:04 +00:00
Suggestions.pm Bug 42645: Use notice_email_address in ModSuggestion SMS fallback check 2026-06-29 15:39:04 +00:00
TTParser.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
Tags.pm Bug 43330: Fix C4::Tags compile failure with TagsExternalDictionary 2026-09-11 15:07:02 +00:00
Templates.pm Bug 41837: Remove $path from C4::Templates 2026-03-09 17:06:50 -06:00
TmplToken.pm Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
TmplTokenType.pm Bug 40680: Move EXPORT_OK right after Modern::Perl 2025-12-01 08:33:56 -07:00
UsageStats.pm Bug 31391: Add UseRecalls to Hea 2026-09-14 14:15:53 +00:00
XISBN.pm Bug 41454: Remove unused dbh calls 2026-04-15 09:14:51 -06:00
XSLT.pm Bug 31391: Implement UseRecalls choices in modules 2026-09-14 14:15:48 +00:00