Permalink
Browse files

Merge branch 'MDL-64205-master-sarunconfirmeduser' of git://github.co…

…m/mudrd8mz/moodle
  • Loading branch information...
dmonllao committed Nov 26, 2018
2 parents 65c6723 + 87bb595 commit b14ad6e17d64666d17bcc541f0fe62551858e5c9
@@ -299,5 +299,19 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018110700, 'tool', 'dataprivacy');
}
if ($oldversion < 2018112500) {
// Delete orphaned data privacy requests.
$sql = "SELECT r.id
FROM {tool_dataprivacy_request} r LEFT JOIN {user} u ON r.userid = u.id
WHERE u.id IS NULL";
$orphaned = $DB->get_fieldset_sql($sql);
if ($orphaned) {
$DB->delete_records_list('tool_dataprivacy_request', 'id', $orphaned);
}
upgrade_plugin_savepoint(true, 2018112500, 'tool', 'dataprivacy');
}
return true;
}
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2018110900;
$plugin->version = 2018112500;
$plugin->requires = 2018050800; // Moodle 3.5dev (Build 2018031600) and upwards.
$plugin->component = 'tool_dataprivacy';
@@ -54,9 +54,8 @@ public function execute() {
WHERE confirmed = 0 AND timecreated > 0
AND timecreated < ? AND deleted = 0", array($cuttime));
foreach ($rs as $user) {
delete_user($user); // We MUST delete user properly first.
$DB->delete_records('user', array('id' => $user->id)); // This is a bloody hack, but it might work.
mtrace(" Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
delete_user($user);
mtrace(" Deleted unconfirmed user ".fullname($user, true)." ($user->id)");
}
$rs->close();
}

0 comments on commit b14ad6e

Please sign in to comment.