Koha-clms/misc
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
..
admin Bug 40545: (follow-up) Correct GNU link 2025-10-15 16:12:02 -06:00
bin Bug 37538: Improve documentation for the OCLC import daemon script 2026-01-12 10:53:30 -07:00
cronjobs Bug 40934: Add --exclude-code option to process_message_queue.pl 2026-09-21 11:56:45 +00:00
devel Bug 38365: Add context to Koha::Devel::Files in add_csp_nonces.pl 2026-03-16 11:57:41 +01:00
interface_customization
…
maintenance Bug 42714: Remove redundant manual cronlogaction calls from scripts 2026-07-28 14:32:32 +00:00
migration_tools Bug 41681: (follow-up) Fix record number count when broken records are processed 2026-07-28 14:32:46 +00:00
release_notes 26.05.00: Add release notes 2026-05-26 14:16:10 -06:00
search_tools Bug 40722: Add a log when resetting mappings during elastic rebuild 2025-10-15 16:12:07 -06:00
translator Bug 41216: (QA follow-up): fix path of xt/author/tt_valid.t in comment 2026-04-10 09:48:11 -06:00
workers Bug 39769: Flush L1 cache in es_indexer_daemon.pl before each batch 2026-08-28 16:36:31 +00:00
add_date_fields_to_marc_records.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
add_statistics_borrowers_categorycode.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchCompareMARCvsFrameworks.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchDeleteUnusedSubfields.pl Bug 39325: Automatic fix 2025-04-28 18:51:22 +02:00
batchImportMARCWithBiblionumbers.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchRebuildBiblioTables.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchRebuildItemsTables.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchRepairMissingBiblionumbers.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
batchdeletebiblios.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
check_sysprefs.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
commit_file.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
export_borrowers.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
export_records.pl Bug 41494: Rename "Koha administration" module name to "Administration" 2026-01-06 07:45:37 -07:00
import_patrons.pl Bug 35061: Fix documentation for -pf|preserve-field in import_patrons.pl 2026-08-21 15:58:20 +00:00
koha-install-log
…
link_bibs_to_authorities.pl Bug 42714: Remove redundant manual cronlogaction calls from scripts 2026-07-28 14:32:32 +00:00
load_yaml.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
mod_zebraqueue.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
process_ill_updates.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
recreateIssueStatistics.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
sax_parser_print.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
sax_parser_test.pl Bug 38664: Tidy the whole codebase 2025-02-11 14:58:24 +01:00
sip_cli_emulator.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
stage_file.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00
z3950_responder.pl Bug 40163: Fix several http addresses in the code docs 2025-09-23 16:21:29 -06:00