MDL-25708 recordsets - fix file_storage
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 3 Jan 2011 16:23:47 +0000 (17:23 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 25 Jan 2011 18:59:00 +0000 (19:59 +0100)
lib/filestorage/file_storage.php

index 679cac1..383da52 100644 (file)
@@ -1214,6 +1214,7 @@ class file_storage {
         foreach ($rs as $dir) {
             $this->delete_area_files($dir->contextid, $dir->component, $dir->filearea, $dir->itemid);
         }
+        $rs->close();
         mtrace('done.');
 
         // remove trash pool files once a day
@@ -1226,12 +1227,14 @@ class file_storage {
                     FROM {files} f
                     LEFT OUTER JOIN {context} c ON f.contextid = c.id
                     WHERE c.id IS NULL";
-            if ($rs = $DB->get_recordset_sql($sql)) {
+            $rs = $DB->get_recordset_sql($sql);
+            if ($rs->valid()) {
                 $fs = get_file_storage();
                 foreach ($rs as $ctx) {
                     $fs->delete_area_files($ctx->contextid);
                 }
             }
+            $rs->close();
             mtrace('done.');
 
             mtrace('Deleting trash files... ', '');