Merge branch 'MDL-33562-23' of git://github.com/danpoltawski/moodle into MOODLE_23_STABLE
[moodle.git] / lib / db / upgrade.php
index cc0cc36..73d48f8 100644 (file)
@@ -1187,5 +1187,14 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2012062507.01);
     }
 
+    if ($oldversion < 2012062507.06) {
+        // Clean up old tokens which haven't been deleted.
+        $DB->execute("DELETE FROM {user_private_key} WHERE NOT EXISTS
+                         (SELECT 'x' FROM {user} WHERE deleted = 0 AND id = userid)");
+
+        // Main savepoint reached.
+        upgrade_main_savepoint(true, 2012062507.06);
+    }
+
     return true;
 }