X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=blobdiff_plain;f=admin%2Ftool%2Fmoodlenet%2Fdb%2Fupgrade.php;h=f1ecf439dfb806f57d2f4c37463bbb1a89a2a2ab;hp=0442276c116f788db2644447130a43a810db0362;hb=ffa17ad17da6ac3745aa6df4ba24087858de9261;hpb=5d6fcc67cf1dfe9d45efc79ed30a6afe115e8cb1 diff --git a/admin/tool/moodlenet/db/upgrade.php b/admin/tool/moodlenet/db/upgrade.php index 0442276c116..f1ecf439dfb 100644 --- a/admin/tool/moodlenet/db/upgrade.php +++ b/admin/tool/moodlenet/db/upgrade.php @@ -105,5 +105,23 @@ function xmldb_tool_moodlenet_upgrade(int $oldversion) { // Automatically generated Moodle v3.9.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2020061503) { + + // Find out if there are users with MoodleNet profiles set. + $sql = "SELECT u.* + FROM {user} u + WHERE u.moodlenetprofile IS NOT NULL"; + + $records = $DB->get_records_sql($sql); + + foreach ($records as $record) { + // Force clean user value just incase there is something malicious. + $record->moodlenetprofile = clean_text($record->moodlenetprofile, PARAM_NOTAGS); + $DB->update_record('user', $record); + } + + upgrade_plugin_savepoint(true, 2020061503, 'tool', 'moodlenet'); + } + return true; }