Merge branch 'master_MDL-66864' of https://github.com/golenkovm/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2019-10-13 02:08:10 +02:00
commit 0b30d47973

View file

@ -2028,16 +2028,18 @@ function xmldb_main_upgrade($oldversion) {
if ($oldversion < 2018092800.02) { if ($oldversion < 2018092800.02) {
// Delete any contacts that are not mutual (meaning they both haven't added each other). // Delete any contacts that are not mutual (meaning they both haven't added each other).
$sql = "SELECT c1.id do {
FROM {message_contacts} c1 $sql = "SELECT c1.id
LEFT JOIN {message_contacts} c2 FROM {message_contacts} c1
ON c1.userid = c2.contactid LEFT JOIN {message_contacts} c2
AND c1.contactid = c2.userid ON c1.userid = c2.contactid
WHERE c2.id IS NULL"; AND c1.contactid = c2.userid
if ($contacts = $DB->get_records_sql($sql)) { WHERE c2.id IS NULL";
list($insql, $inparams) = $DB->get_in_or_equal(array_keys($contacts)); if ($contacts = $DB->get_records_sql($sql, null, 0, 1000)) {
$DB->delete_records_select('message_contacts', "id $insql", $inparams); list($insql, $inparams) = $DB->get_in_or_equal(array_keys($contacts));
} $DB->delete_records_select('message_contacts', "id $insql", $inparams);
}
} while ($contacts);
upgrade_main_savepoint(true, 2018092800.02); upgrade_main_savepoint(true, 2018092800.02);
} }