]> git.mjollnir.org Git - moodle.git/commitdiff
add proper rs_close() into cleanup_contexts() - we have to close even when now record...
authorskodak <skodak>
Wed, 10 Oct 2007 08:43:25 +0000 (08:43 +0000)
committerskodak <skodak>
Wed, 10 Oct 2007 08:43:25 +0000 (08:43 +0000)
lib/accesslib.php

index 765851eea5d4ca40632a104a18f2263cbcac00c8..966518d9eb7728c0ed16acce9093c188a8e8022c 100755 (executable)
@@ -2442,20 +2442,22 @@ function cleanup_contexts() {
                 ON c.instanceid = t.id
               WHERE t.id IS NULL AND c.contextlevel = " . CONTEXT_GROUP . "
            ";
-    $rs = get_recordset_sql($sql);
-    if ($rs->RecordCount()) {
-        begin_sql();
-        $tx = true;
-        while ($tx && $ctx = rs_fetch_next_record($rs)) {
-            $tx = $tx && delete_context($ctx->level, $ctx->instanceid);
+    if ($rs = get_recordset_sql($sql)) {
+        if ($rs->RecordCount()) {
+            begin_sql();
+            $tx = true;
+            while ($tx && $ctx = rs_fetch_next_record($rs)) {
+                $tx = $tx && delete_context($ctx->level, $ctx->instanceid);
+            }
+            rs_close($rs);
+            if ($tx) {
+                commit_sql();
+                return true;
+            }
+            rollback_sql();
+            return false;
         }
         rs_close($rs);
-        if ($tx) {
-            commit_sql();
-            return true;
-        }
-        rollback_sql();
-        return false;
     }
     return true;
 }