MDL-27405 navigation: Improved checking when fetching all parent categories
authorSam Hemelryk <sam@moodle.com>
Tue, 6 Mar 2012 21:41:30 +0000 (10:41 +1300)
committerSam Hemelryk <sam@moodle.com>
Sun, 11 Mar 2012 20:42:41 +0000 (09:42 +1300)
lib/navigationlib.php

index da26d5c..33835df 100644 (file)
@@ -1087,7 +1087,10 @@ class global_navigation extends navigation_node {
 
                 if (count($categoryids)) {
                     // Fetch any other categories we need.
-                    $categories = array_merge($DB->get_records_list('course_categories', 'id', $categoryids, 'depth ASC, sortorder ASC'), $categories);
+                    $allcategories = $DB->get_records_list('course_categories', 'id', $categoryids, 'depth ASC, sortorder ASC');
+                    if (is_array($allcategories) && count($allcategories) > 0) {
+                        $categories = array_merge($categories);
+                    }
                 }
 
                 // We ONLY want the categories, we need to get rid of the keys