Bugzilla – Attachment 171756 Details for
Bug 37885
Add ability to disable message queue processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37885: Add ability to disable message queue processing
Bug-37885-Add-ability-to-disable-message-queue-pro.patch (text/plain), 6.52 KB, created by
Kyle M Hall (khall)
on 2024-09-19 13:37:09 UTC
(
hide
)
Description:
Bug 37885: Add ability to disable message queue processing
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-09-19 13:37:09 UTC
Size:
6.52 KB
patch
obsolete
>From a2f236ae6b9e9159b55c6d18aa8d2c3006c3af63 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 19 Sep 2024 09:29:56 -0400 >Subject: [PATCH] Bug 37885: Add ability to disable message queue processing > >There exist services that libraries utilize as an alternative to processing the message queue. >These services may utilize the queued messages and send them from outside of Koha. >Sometimes these services utilize the API or reports while other times they utilize a plugin. >It would be beneficial to be able to disable running the message queue processor altogether, >or to only execute the plugin hook related to message queue processing ( before_send_messages ) >to limit the processing of messages to those handled by plugins. > >Test Plan: >1) Apply this patch >2) Run updatedatabase.pl >3) Install the kitchen sink plugin, enable it >4) Enqueue a notice >5) Set MessageQueueMode to "process nothing" >6) Run process_message_queue.pl >7) Note nothing happens, 0 message reported >8) Set MessageQueueMode to "process plugin hooks only" >9) Run process_message_queue.pl >10) Note nothing happens, 0 message reported >11) Set MessageQueueMode to "on" >12) Run process_message_queue.pl >13) Note the message fails to send, assuming you have not set > up anything to actually send messages on your test instance >--- > C4/Letters.pm | 6 +++ > installer/data/mysql/mandatory/sysprefs.sql | 1 + > .../en/modules/admin/preferences/admin.pref | 9 ++++ > t/db_dependent/Letters.t | 45 ++++++++++++++++++- > 4 files changed, 60 insertions(+), 1 deletion(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index ce8ffda7e17..a93303d55de 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1021,6 +1021,10 @@ sub SendQueuedMessages { > Koha::Exceptions::BadParameter->throw("Parameter message_id cannot be empty if passed.") > if ( exists( $params->{message_id} ) && !$params->{message_id} ); > >+ my $MessageQueueMode = C4::Context->preference('MessageQueueMode'); >+ >+ return 0 unless ( $MessageQueueMode eq 'on' || $MessageQueueMode eq 'plugin' ); >+ > if ( C4::Context->config("enable_plugins") ) { > my @plugins = Koha::Plugins->new->GetPlugins({ > method => 'before_send_messages', >@@ -1038,6 +1042,8 @@ sub SendQueuedMessages { > } > } > >+ return 0 unless ( $MessageQueueMode eq 'on' ); >+ > my $smtp_transports = {}; > > my $count_messages = 0; >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 20d11d36ab3..9893b9b5cdc 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -411,6 +411,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('MaxTotalSuggestions','',NULL,'Number of total suggestions used for time limit with NumberOfSuggestionDays','Free'), > ('MembershipExpiryDaysNotice','',NULL,'Send an account expiration notice that a patron\'s card is about to expire after','Integer'), > ('MergeReportFields','',NULL,'Displayed fields for deleted MARC records after merge','Free'), >+('MessageQueueMode','on','on|off|plugins','Search Engine','Choice'), > ('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'), > ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), > ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index 511341f0444..10856577d0d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -301,3 +301,12 @@ Administration: > "ARRAY": "Searchable array" > - <br>ISO2709 format is recommended as it is faster and takes less space, whereas array format makes the full MARC record searchable. > - <br><strong>NOTE:</strong> Making the full record searchable may have a negative effect on relevance ranking of search results. >+ Message processing: >+ - >+ - "When running the message queue processor" >+ - pref: MessageQueueMode >+ default: on >+ choices: >+ on: process all messages and plugin hooks >+ plugins: process plugin hooks only >+ off: process nothing >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index fbe496d7ac6..5f8426054a1 100755 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > use File::Basename qw(dirname); >-use Test::More tests => 103; >+use Test::More tests => 104; > > use Test::MockModule; > use Test::Warn; >@@ -1582,3 +1582,46 @@ subtest 'Quote user params in GetPreparedLetter' => sub { > $exec_time > ); > }; >+ >+subtest 'Test MessageQueueMode' => sub { >+ plan tests => 3; >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $borrowernumber = Koha::Patron->new({ >+ firstname => 'Jane', >+ surname => 'Smith', >+ categorycode => $patron_category, >+ branchcode => $library->{branchcode}, >+ dateofbirth => $date, >+ })->store->borrowernumber; >+ >+ $dbh->do(q|DELETE FROM message_queue|); >+ $my_message = { >+ 'letter' => { >+ 'content' => 'a message', >+ 'metadata' => 'metadata', >+ 'code' => 'TEST_MESSAGE', >+ 'content_type' => 'text/plain', >+ 'title' => 'message title' >+ }, >+ 'borrowernumber' => $borrowernumber, >+ 'to_address' => undef, >+ 'message_transport_type' => 'sms', >+ 'from_address' => 'from@example.com' >+ }; >+ >+ my $id = C4::Letters::EnqueueLetter($my_message); >+ >+ t::lib::Mocks::mock_preference('MessageQueueMode', 'off'); >+ C4::Letters::SendQueuedMessages(); >+ is( Koha::Notice::Messages->find( $id )->status, 'pending', 'Message is pending for off' ); >+ >+ t::lib::Mocks::mock_preference('MessageQueueMode', 'plugin'); >+ C4::Letters::SendQueuedMessages(); >+ is( Koha::Notice::Messages->find( $id )->status, 'pending', 'Message is pending for plugin' ); >+ >+ t::lib::Mocks::mock_preference('MessageQueueMode', 'on'); >+ C4::Letters::SendQueuedMessages(); >+ is( Koha::Notice::Messages->find( $id )->status, 'failed', 'Message is failed for on' ); >+}; >-- >2.39.5 (Apple Git-154)
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 37885
:
171756
|
171757
|
171789