Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails
Summary: Add ability to exit process_message_queue.pl early if any plugin before_send_...
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Kyle M Hall (khall)
QA Contact: Victor Grousset/tuxayo
URL:
Keywords: rel_22_11_candidate
Depends on:
Blocks:
 
Reported: 2022-08-11 19:43 UTC by Kyle M Hall (khall)
Modified: 2024-05-28 21:10 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.05.00,23.11.06,23.05.12
Circulation function:


Attachments
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails (2.09 KB, patch)
2022-08-11 19:46 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails (2.08 KB, patch)
2022-11-07 19:19 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails (2.04 KB, patch)
2023-09-05 16:11 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails (2.09 KB, patch)
2024-02-08 19:00 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 31345: Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails (2.15 KB, patch)
2024-04-29 00:31 UTC, Victor Grousset/tuxayo
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 (khall) 2022-08-11 19:43:08 UTC
Sometimes it would be better for process_message_queue.pl to stop if a plugin hook fails rather than continue processing. It would be nice if that was a command line option.
Comment 1 Kyle M Hall (khall) 2022-08-11 19:46:25 UTC
Created attachment 139027 [details] [review]
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails

Sometimes it would be better for process_message_queue.pl to stop if a plugin hook fails rather than continue processing. It would be nice if that was a command line option.

Test Plan:
1) Install any plugin with a before_send_messages hook
2) Modify the plugin, add a 'die;' statement at the start of the
   before_send_messages method of the plugin.
3) Run process_message_queue.pl as usual
4) Note the exit code is 0
5) Run it again with the new -e setting
6) Note the exit code is 1
Comment 2 Tomás Cohen Arazi (tcohen) 2022-11-01 17:24:34 UTC
Trivial and handy minor enh.
Comment 3 Kyle M Hall (khall) 2022-11-07 19:19:05 UTC
Created attachment 143381 [details] [review]
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails

Sometimes it would be better for process_message_queue.pl to stop if a plugin hook fails rather than continue processing. It would be nice if that was a command line option.

Test Plan:
1) Install any plugin with a before_send_messages hook
2) Modify the plugin, add a 'die;' statement at the start of the
   before_send_messages method of the plugin.
3) Run process_message_queue.pl as usual
4) Note the exit code is 0
5) Run it again with the new -e setting
6) Note the exit code is 1
Comment 4 Kyle M Hall (khall) 2023-09-05 16:11:44 UTC
Created attachment 155227 [details] [review]
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails

Sometimes it would be better for process_message_queue.pl to stop if a plugin hook fails rather than continue processing. It would be nice if that was a command line option.

Test Plan:
1) Install any plugin with a before_send_messages hook
2) Modify the plugin, add a 'die;' statement at the start of the
   before_send_messages method of the plugin.
3) Run process_message_queue.pl as usual
4) Note the exit code is 0
5) Run it again with the new -e setting
6) Note the exit code is 1
Comment 5 Brendan Lawlor 2024-02-07 20:45:25 UTC
Tried testing, but not sure if I did it right.

Notes:

I was able to install the kitchen sink plugin in ktd.
I added some lines to the beginning of sub before_send_messages like
    print "die! " . Data::Dumper::Dumper("dead");
    die;

Then cd to /koha/misc/cronjobs and run
perl process_message_queue.pl
Argument "{VERSION}" isn't numeric in int at /kohadevbox/koha/Koha/Plugins/Base.pm line 339.
Argument "{VERSION}" isn't numeric in int at /kohadevbox/koha/Koha/Plugins/Base.pm line 339.
die!$VAR1 = ' dead';
Died at /kohadevbox/koha_plugin/dev-koha-plugin-kitchen-sink/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm line 605.

It doesn't show the exit code but I guess that's what exit code 0 looks like.

Applied patch and ran 
perl -e process_message_queue.pl

That didn't output anything, is that what's expected for exit code 1?
Comment 6 Kyle M Hall (khall) 2024-02-08 18:25:43 UTC
> Applied patch and ran 
> perl -e process_message_queue.pl
> 
> That didn't output anything, is that what's expected for exit code 1?

After running the command, run:
echo $?
on the command line and it will give you the exit code of the last command you ran!
Comment 7 Brendan Lawlor 2024-02-08 19:00:40 UTC
Created attachment 161952 [details] [review]
Bug 31345 - Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails

Sometimes it would be better for process_message_queue.pl to stop if a plugin hook fails rather than continue processing. It would be nice if that was a command line option.

Test Plan:
1) Install any plugin with a before_send_messages hook
2) Modify the plugin, add a 'die;' statement at the start of the
   before_send_messages method of the plugin.
3) Run process_message_queue.pl as usual
4) Note the exit code is 0
5) Run it again with the new -e setting
6) Note the exit code is 1

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 8 Brendan Lawlor 2024-02-08 19:03:10 UTC
Cool, that worked.

Also found I had the -e option in the wrong place in the command.

kohadev-koha@kohadevbox:cronjobs(master)$ perl process_message_queue.pl 
die! $VAR1 = 'dead';
Died at /kohadevbox/koha_plugin/dev-koha-plugin-kitchen-sink/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm line 211.
kohadev-koha@kohadevbox:cronjobs(master)$ echo $?
0
kohadev-koha@kohadevbox:cronjobs(master)$ perl -e process_message_queue.pl 
kohadev-koha@kohadevbox:cronjobs(master)$ echo $?
0
kohadev-koha@kohadevbox:cronjobs(master)$ perl process_message_queue.pl -e
die! $VAR1 = 'dead';
Died at /kohadevbox/koha_plugin/dev-koha-plugin-kitchen-sink/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm line 211.
kohadev-koha@kohadevbox:cronjobs(master)$ echo $?
1
Comment 9 Victor Grousset/tuxayo 2024-04-29 00:31:46 UTC
Created attachment 165712 [details] [review]
Bug 31345: Add ability to exit process_message_queue.pl early if any plugin before_send_messages hook fails

Sometimes it would be better for process_message_queue.pl to stop if a plugin hook fails rather than continue processing. It would be nice if that was a command line option.

Test Plan:
1) Install any plugin with a before_send_messages hook
2) Modify the plugin, add a 'die;' statement at the start of the
   before_send_messages method of the plugin.
3) Run process_message_queue.pl as usual
4) Note the exit code is 0
5) Run it again with the new -e setting
6) Note the exit code is 1

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 10 Victor Grousset/tuxayo 2024-04-29 00:34:35 UTC
Works, makes sense, QA script happy, code looks good, passing QA :)

---

Fixed commit message format.
Comment 11 Katrin Fischer 2024-04-29 16:55:16 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 12 Fridolin Somers 2024-05-24 12:09:08 UTC
Pushed to 23.11.x for 23.11.06
Comment 13 Lucas Gass (lukeg) 2024-05-28 21:10:47 UTC
Backported to 23.05.x for upcoming 23.05.12