-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
4.1.18
-
MOODLE_401_STABLE
Context
Weekly version of Moodle 4.1.18, with mysql 8.0.
At our institution we have the Moodle core services for notifications activated, including the official Mobile App. Also, we have this other plugin installed and configured: https://moodle.org/plugins/message_appcrue
We faced a problem on the plugin https://moodle.org/plugins/message_appcrue on one of the last updates and produced error on every notification being tried to push.
The stack trace was this, just to provide full detail of the process being executed:
Adhoc task failed: mod_forum\task\send_user_notifications,Object of class stdClass could not be converted to string
|
Backtrace:
|
* line 183 of /message/output/appcrue/message_output_appcrue.php: call to message_output_appcrue->send_api_message_chunk()
|
* line 110 of /message/output/appcrue/message_output_appcrue.php: call to message_output_appcrue->send_api_message()
|
* line 506 of /lib/classes/message/manager.php: call to message_output_appcrue->send_message()
|
* line 382 of /lib/classes/message/manager.php: call to core\message\manager::call_processors()
|
* line 349 of /lib/classes/message/manager.php: call to core\message\manager::send_message_to_processors()
|
* line 341 of /lib/messagelib.php: call to core\message\manager::send_message()
|
* line 386 of /mod/forum/classes/task/send_user_notifications.php: call to message_send()
|
* line 155 of /mod/forum/classes/task/send_user_notifications.php: call to mod_forum\task\send_user_notifications->send_post()
|
* line 367 of /lib/cronlib.php: call to mod_forum\task\send_user_notifications->execute()
|
* line 198 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
|
* line 131 of /admin/cli/adhoc_task.php: call to cron_run_adhoc_tasks()
|
All these notifications are sent through the adhoc task: /mod/forum/classes/task/send_user_notifications.php
Problem
For users with the notification activated for message_appcrue produced an error on the whole adhoc task, so adhoc task was requeued to be retried again, and again.
This made those users with message_appcrue receive several times (dozens of times) the same email, the same notification inside the Moodle, and so on, all due to the message_appcrue fault.
Proposal
The idea behind this issue is to prevent re-sending notifications that were already sent successfully, and re-try only the specific notification channel that was faulting.
Some proposals could be:
- Construct additional adhoc task to process specific output message plugins or similar. Maybe core ones could be addressed with the current adhoc task, and any extra, non-core, notification services could be addressed with additional adhoc task.
- On one extrem, a specific adhoc task could be set up to deliver some specific notification with some specific notification service. And by "notification service" I mean: email, official Moodle app, message_appcrue, notification inside Moodle, etc.
- Keep the current adhoc task but registering which notification services were completed previously. So, the first time, the list of completed notification services should be empty, and, in presence of errors, those notification services being completed would be included in the list. So when running the requeued adhoc task would skip completed notification services and would only try additional notification services not completed.
- In our case, requeued adhoc task would have the list of notification services completed as: email, Moodle notification and Moodle App. Processing the adhoc task would only retry the appcrue message plugin.
Final remark
I do not know if this is really an improvement request or a bug. I let you modify at your will. I mark Moodle 4.1.18 as affected version, but I do not know if this still applies to supported upper versions.