Skip to content

Commit

Permalink
MDL-63712 core_message: Minor provider improvements
Browse files Browse the repository at this point in the history
This issue is part of the MDL-62560 Epic.
  • Loading branch information
mickhawkins committed Nov 1, 2018
1 parent 23d4767 commit a05d4df
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions message/classes/privacy/provider.php
Expand Up @@ -184,7 +184,7 @@ public static function get_users_in_context(userlist $userlist) {
$userid = $context->instanceid;

// Messages are in the user context.
// For the sake of performance, there is no need to call add_from_sql for each of the bellow cases.
// For the sake of performance, there is no need to call add_from_sql for each of the below cases.
// It is enough to add the user's context as soon as we come to the conclusion that the user has some data.
// Also, the order of checking is sorted by the probability of occurrence (just by guess).

Expand Down Expand Up @@ -298,10 +298,8 @@ public static function delete_data_for_users(approved_userlist $userlist) {
protected static function delete_user_data(int $userid) {
global $DB;

$DB->delete_records_select('message', 'useridfrom = ? AND notification = 0', [$userid]);
$DB->delete_records_select('message_read', 'useridfrom = ? AND notification = 0', [$userid]);
$DB->delete_records_select('message', '(useridfrom = ? OR useridto = ?) AND notification = 1', [$userid, $userid]);
$DB->delete_records_select('message_read', '(useridfrom = ? OR useridto = ?) AND notification = 1', [$userid, $userid]);
$DB->delete_records_select('message', 'useridfrom = ? OR (useridto = ? AND notification = 1)', [$userid, $userid]);
$DB->delete_records_select('message_read', 'useridfrom = ? OR (useridto = ? AND notification = 1)', [$userid, $userid]);
$DB->delete_records_select('message_contacts', 'userid = ? OR contactid = ?', [$userid, $userid]);
}

Expand Down

0 comments on commit a05d4df

Please sign in to comment.