Bug 28474 - Pass process_message_queue.pl params to before_send_messages plugin hooks
Summary: Pass process_message_queue.pl params to before_send_messages plugin hooks
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Kyle M Hall
QA Contact: Testopia
URL:
Keywords:
Depends on: 24183
Blocks: 35148
  Show dependency treegraph
 
Reported: 2021-05-27 13:27 UTC by Kyle M Hall
Modified: 2023-10-26 08:26 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This enhancement passes the parameters received by process_message_queue.pl through to the before_send_messages plugin calls. This allows plugins to respect calls that should only affect certain letter codes etc.
Version(s) released in:
21.11.00,21.05.05,20.11.12


Attachments
Bug 28474: Pass process_message_queue.pl params to before_send_messages plugin hooks (1.96 KB, patch)
2021-05-27 13:55 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 28474: Pass process_message_queue.pl params to before_send_messages plugin hooks (2.01 KB, patch)
2021-10-12 14:45 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 28474: Pass process_message_queue.pl params to before_send_messages plugin hooks (2.06 KB, patch)
2021-11-01 21:08 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2021-05-27 13:27:36 UTC
It would be useful to send most of the process_message_queue.pl script parameters to any plugin before_send_messages hooks. For example, the Twilio Voice plugin uses before_send_messages to send phone messages, but if the script is called with "-t email", it doesn't know and will make phone calls! If that info were passed in, the plugin could be made aware of it and only make calls if no "-t" or a "-t phone" were set in the parameters.
Comment 1 Kyle M Hall 2021-05-27 13:55:28 UTC
Created attachment 121452 [details] [review]
Bug 28474: Pass process_message_queue.pl params to before_send_messages plugin hooks

It would be useful to send most of the process_message_queue.pl script parameters to any plugin before_send_messages hooks. For example, the Twilio Voice plugin uses before_send_messages to send phone messages, but if the script is called with "-t email", it doesn't know and will make phone calls! If that info were passed in, the plugin could be made aware of it and only make calls if no "-t" or a "-t phone" were set in the parameters.

Test Plan:
1) Apply this patch
2) Install Kitchen Sink plugin v2.2.0 or later
   https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink/releases/download/v2.2.0/dev-koha-plugin-kitchen-sink-2.2.0.kpz
3) Run misc/cronjobs/process_message_queue.pl with any or all non-email
   related paramters
4) Note the plugin output shows the parameters were passed to the plugin
Comment 2 Andrew Fuerste-Henry 2021-10-12 14:45:16 UTC
Created attachment 126090 [details] [review]
Bug 28474: Pass process_message_queue.pl params to before_send_messages plugin hooks

It would be useful to send most of the process_message_queue.pl script parameters to any plugin before_send_messages hooks. For example, the Twilio Voice plugin uses before_send_messages to send phone messages, but if the script is called with "-t email", it doesn't know and will make phone calls! If that info were passed in, the plugin could be made aware of it and only make calls if no "-t" or a "-t phone" were set in the parameters.

Test Plan:
1) Apply this patch
2) Install Kitchen Sink plugin v2.2.0 or later
   https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink/releases/download/v2.2.0/dev-koha-plugin-kitchen-sink-2.2.0.kpz
3) Run misc/cronjobs/process_message_queue.pl with any or all non-email
   related paramters
4) Note the plugin output shows the parameters were passed to the plugin

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 3 Katrin Fischer 2021-11-01 15:15:32 UTC
I got a little stuck here.

I activated plugins and installed the kitchensink plugin from the link below.

But I am not sure about the parameters to run the misc/cronjobs/process_message_queue.pl with and where in the plugin the output would show.

If I click on "Run report" from the plugin management screen, the plugin dies:
The method Koha::Patron::Categories->search_limited is not covered by tests!

Run tool appears to work.

Sending back to Kyle for clarification.
Comment 4 Kyle M Hall 2021-11-01 16:23:10 UTC
(In reply to Katrin Fischer from comment #3)
> I got a little stuck here.
> 
> I activated plugins and installed the kitchensink plugin from the link below.
> 
> But I am not sure about the parameters to run the
> misc/cronjobs/process_message_queue.pl with and where in the plugin the
> output would show.
> 
> If I click on "Run report" from the plugin management screen, the plugin
> dies:
> The method Koha::Patron::Categories->search_limited is not covered by tests!
> 
> Run tool appears to work.
> 
> Sending back to Kyle for clarification.

Pass something parameter like "-t email" and you should see it in the plugin output. That error on the report side shouldn't affect it, but I'll take a look at that too!
Comment 5 Katrin Fischer 2021-11-01 16:24:08 UTC
> 
> Pass something parameter like "-t email" and you should see it in the plugin
> output. That error on the report side shouldn't affect it, but I'll take a
> look at that too!

Sorry... what and where is the plugin output?
Comment 6 Kyle M Hall 2021-11-01 17:55:08 UTC
(In reply to Katrin Fischer from comment #5)
> > 
> > Pass something parameter like "-t email" and you should see it in the plugin
> > output. That error on the report side shouldn't affect it, but I'll take a
> > look at that too!
> 
> Sorry... what and where is the plugin output?

if you run something like "./misc/cronjobs/process_message_queue.pl -t email" you should see some output from the script like: 

Plugin hook before_send_message called with the params: $VAR1 = {
          'limit' => undef,
          'letter_code' => undef,
          'verbose' => undef,
          'type' => 'email'
        };

on the command line
Comment 7 Katrin Fischer 2021-11-01 21:08:15 UTC
Created attachment 127199 [details] [review]
Bug 28474: Pass process_message_queue.pl params to before_send_messages plugin hooks

It would be useful to send most of the process_message_queue.pl script parameters to any plugin before_send_messages hooks. For example, the Twilio Voice plugin uses before_send_messages to send phone messages, but if the script is called with "-t email", it doesn't know and will make phone calls! If that info were passed in, the plugin could be made aware of it and only make calls if no "-t" or a "-t phone" were set in the parameters.

Test Plan:
1) Apply this patch
2) Install Kitchen Sink plugin v2.2.0 or later
   https://github.com/bywatersolutions/dev-koha-plugin-kitchen-sink/releases/download/v2.2.0/dev-koha-plugin-kitchen-sink-2.2.0.kpz
3) Run misc/cronjobs/process_message_queue.pl with any or all non-email
   related paramters
4) Note the plugin output shows the parameters were passed to the plugin

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Jonathan Druart 2021-11-03 14:31:04 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 9 Kyle M Hall 2021-11-05 18:20:46 UTC
Pushed to 21.05.x for 21.05.05
Comment 10 Kyle M Hall 2021-11-05 18:21:02 UTC
Backported for plugins compatibility.
Comment 11 Fridolin Somers 2021-11-12 22:33:27 UTC
Pushed to 20.11.x for 20.11.12
(Backported for plugins compatibility)
Comment 12 Victor Grousset/tuxayo 2021-11-16 08:13:41 UTC
Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed.