From 20253ec57b5e6ad625690a66cc472ad9c0d2915b Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 5 Jun 2012 16:40:40 +0800 Subject: [PATCH] MDL-33441 course/lib.php prevent fatal error when no visible categories --- course/lib.php | 5 +++++ 1 file changed, 5 insertions(+) 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');