Skip to content

Commit

Permalink
Merge branch 'MDL-47805-master' of git://github.com/ankitagarwal/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Oct 29, 2014
2 parents cf63799 + a8ea7cc commit 412430c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions admin/tool/monitor/classes/notification_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}
}
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions admin/tool/monitor/tests/eventobservers_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,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.
}

/**
Expand Down

0 comments on commit 412430c

Please sign in to comment.