Skip to content

Commit

Permalink
MDL-70285 completion upgrade: fix performance of the MDL-69687 code
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Nov 23, 2020
1 parent c8d33eb commit a6edd14
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/db/upgrade.php
Expand Up @@ -2786,11 +2786,12 @@ function xmldb_main_upgrade($oldversion) {
if ($oldversion < 2021052500.26) {
// Delete orphaned course_modules_completion rows; these were not deleted properly
// by remove_course_contents function.
$DB->delete_records_subquery('course_modules_completion', 'id', 'id',
"SELECT cmc.id
FROM {course_modules_completion} cmc
LEFT JOIN {course_modules} cm ON cm.id = cmc.coursemoduleid
WHERE cm.id IS NULL");
$DB->delete_records_select('course_modules_completion', "
NOT EXISTS (
SELECT 1
FROM {course_modules} cm
WHERE cm.id = {course_modules_completion}.coursemoduleid
)");
upgrade_main_savepoint(true, 2021052500.26);
}

Expand Down

0 comments on commit a6edd14

Please sign in to comment.