Skip to content
Permalink
Browse files
Merge branch 'MDL-64205-35-sarunconfirmeduser' of git://github.com/mu…
…drd8mz/moodle into MOODLE_35_STABLE
  • Loading branch information
David Monllao committed Nov 26, 2018
2 parents e3a1c26 + 690e03b commit 89d45109aa0e5f6e252a4449e9ce867d57afdc31
Showing with 17 additions and 4 deletions.
  1. +14 −0 admin/tool/dataprivacy/db/upgrade.php
  2. +1 −1 admin/tool/dataprivacy/version.php
  3. +2 −3 lib/classes/task/delete_unconfirmed_users_task.php
@@ -262,5 +262,19 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018051413, 'tool', 'dataprivacy');
}

if ($oldversion < 2018051415) {
// 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, 2018051415, 'tool', 'dataprivacy');
}

return true;
}
@@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2018051414;
$plugin->version = 2018051415;
$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 89d4510

Please sign in to comment.