From a8ea7ccccebb068a8343167ee09d33823be10ddf Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Wed, 22 Oct 2014 09:44:21 +0530 Subject: [PATCH] MDL-47805 tool_monitor: More info in adhoc task --- admin/tool/monitor/classes/notification_task.php | 6 ++++++ admin/tool/monitor/tests/eventobservers_test.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/admin/tool/monitor/classes/notification_task.php b/admin/tool/monitor/classes/notification_task.php index ffb1f4a6b5789..150129c6a367e 100644 --- a/admin/tool/monitor/classes/notification_task.php +++ b/admin/tool/monitor/classes/notification_task.php @@ -45,7 +45,9 @@ public function execute() { $subscriptionids = $data->subscriptionids; foreach ($subscriptionids as $id) { if ($message = $this->generate_message($id, $eventobj)) { + mtrace("Sending message to the user with id " . $message->userto->id . " for the subscription with id $id..."); message_send($message); + mtrace("Sent."); } } } @@ -68,6 +70,10 @@ protected function generate_message($subscriptionid, \stdClass $eventobj) { return false; } $user = \core_user::get_user($subscription->userid); + if (empty($user)) { + // User doesn't exist. Should never happen, nothing to do return. + return false; + } $context = \context_user::instance($user->id, IGNORE_MISSING); if ($context === false) { // User context doesn't exist. Should never happen, nothing to do return. diff --git a/admin/tool/monitor/tests/eventobservers_test.php b/admin/tool/monitor/tests/eventobservers_test.php index b8d178ab73d42..2b807e7f480d9 100644 --- a/admin/tool/monitor/tests/eventobservers_test.php +++ b/admin/tool/monitor/tests/eventobservers_test.php @@ -269,10 +269,12 @@ public function test_process_event() { * Run adhoc tasks. */ protected function run_adhock_tasks() { + ob_start(); while ($task = \core\task\manager::get_next_adhoc_task(time())) { $task->execute(); \core\task\manager::adhoc_task_complete($task); } + ob_clean(); // Suppress mtrace debugging info. } /**