]> git.mjollnir.org Git - moodle.git/commitdiff
Prevent 'Warning: Invalid argument supplied for foreach() in ...' for get_courses_pag...
authordwoolhead <dwoolhead>
Fri, 22 Sep 2006 11:15:10 +0000 (11:15 +0000)
committerdwoolhead <dwoolhead>
Fri, 22 Sep 2006 11:15:10 +0000 (11:15 +0000)
lib/datalib.php

index e31fb027294804e9d366e0753b5862ba079460d7..e3b59c0b0343925aa701d88e2e41ae25764c5b79 100644 (file)
@@ -576,11 +576,13 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
     }  
     
     // pull out all course matching the cat
-    $courses = get_records_sql("SELECT $fields 
+    $visiblecourses = array();
+    if (!($courses = get_records_sql("SELECT $fields 
                                 FROM {$CFG->prefix}course c 
                                 $categoryselect
-                                ORDER BY $sort");
-    $visiblecourses = array();
+                                ORDER BY $sort"))) {
+        return $visiblecourses;
+    }
     $totalcount = 0;
     
     if (!$limitnum) {
@@ -1515,4 +1517,4 @@ function category_parent_visible($parent = 0) {
 }
 
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
+?>
\ No newline at end of file