diff --git a/course/lib.php b/course/lib.php index 766c775adf3..3384bf3db41 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2091,6 +2091,11 @@ function get_course_category_tree($id = 0, $depth = 0) { return array($categories, $categoryids); } + if (empty($categoryids)) { + // No categories available (probably all hidden). + return array(); + } + // The depth is 0 this function has just been called so we can finish it off list($ccselect, $ccjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');