mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-64205 privacy: Delete orphaned data request records on upgrade
As a result of the bug, some requests can be orphaned - the linked user record may not exist any more. This is a cleanup of such records.
This commit is contained in:
parent
8b52601b1a
commit
87bb5954eb
@ -299,5 +299,19 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
|
|||||||
upgrade_plugin_savepoint(true, 2018110700, 'tool', 'dataprivacy');
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,6 @@
|
|||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die;
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
$plugin->version = 2018110900;
|
$plugin->version = 2018112500;
|
||||||
$plugin->requires = 2018050800; // Moodle 3.5dev (Build 2018031600) and upwards.
|
$plugin->requires = 2018050800; // Moodle 3.5dev (Build 2018031600) and upwards.
|
||||||
$plugin->component = 'tool_dataprivacy';
|
$plugin->component = 'tool_dataprivacy';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user