MDL-57649 mod_lesson: Additional refinement to upgrade script.
authorAdrian Greeve <adrian@moodle.com>
Wed, 19 Jul 2017 07:44:42 +0000 (15:44 +0800)
committerAdrian Greeve <adrian@moodle.com>
Wed, 19 Jul 2017 07:44:42 +0000 (15:44 +0800)
mod/lesson/db/upgrade.php

index 6c9baf7..c030dc8 100644 (file)
@@ -148,9 +148,11 @@ function xmldb_lesson_upgrade($oldversion) {
                   FROM {files} f
              LEFT JOIN {lesson_answers} la ON f.itemid = la.id
                  WHERE component = :component
+                   AND (filearea = :fileareaanswer OR filearea = :filearearesponse)
                    AND la.id IS NULL";
 
-        $orphanedfiles = $DB->get_recordset_sql($sql, array('component' => 'mod_lesson'));
+        $orphanedfiles = $DB->get_recordset_sql($sql, array('component' => 'mod_lesson', 'fileareaanswer' => 'page_answers',
+                'filearearesponse' => 'page_responses'));
         $fs = get_file_storage();
         foreach ($orphanedfiles as $file) {
             $fs->delete_area_files($file->contextid, $file->component, $file->filearea, $file->itemid);