Description
Kyle M Hall (khall)
2022-08-11 19:43:08 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 Trivial and handy minor enh. 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 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 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? > 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!
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> 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 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> Works, makes sense, QA script happy, code looks good, passing QA :) --- Fixed commit message format. Pushed for 24.05! Well done everyone, thank you! Pushed to 23.11.x for 23.11.06 Backported to 23.05.x for upcoming 23.05.12 Could I please get a link to an appropriate plugin and a more detailed test plan if this is required for 22.11? |