Skip to content

Commit

Permalink
Merge branch 'MDL-64205-master-sarunconfirmeduser' of git://github.co…
Browse files Browse the repository at this point in the history
…m/mudrd8mz/moodle
  • Loading branch information
David Monllao committed Nov 26, 2018
2 parents 65c6723 + 87bb595 commit b14ad6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
14 changes: 14 additions & 0 deletions admin/tool/dataprivacy/db/upgrade.php
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion admin/tool/dataprivacy/version.php
Expand Up @@ -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';
5 changes: 2 additions & 3 deletions lib/classes/task/delete_unconfirmed_users_task.php
Expand Up @@ -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();
}
Expand Down

0 comments on commit b14ad6e

Please sign in to comment.