MDL-57967 core_message: do not process conversations from deleted users

This commit is contained in:
Mark Nelson
2017-02-16 13:01:06 +08:00
parent 7a3b115d37
commit f512355b31
2 changed files with 42 additions and 1 deletions
+7 -1
View File
@@ -417,7 +417,8 @@ class api {
$userfields = \user_picture::fields('', array('lastaccess'));
$userssql = "SELECT $userfields
FROM {user}
WHERE id $useridsql";
WHERE id $useridsql
AND deleted = 0";
$otherusers = $DB->get_records_sql($userssql, $usersparams);
// Similar to the above use case, we need to pull the contact information and again this has
@@ -478,6 +479,11 @@ class api {
$conversation->$prop = ($otheruser) ? $otheruser->$prop : null;
}
// Do not process a conversation with a deleted user.
if (empty($conversation->id)) {
continue;
}
// Add the contact's information, if we have one.
$conversation->blocked = ($contact) ? $contact->blocked : null;