Merge branch 'MDL-66336_master' of https://github.com/marxjohnson/moodle
authorJun Pataleta <jun@moodle.com>
Wed, 21 Aug 2019 14:41:41 +0000 (22:41 +0800)
committerJun Pataleta <jun@moodle.com>
Wed, 21 Aug 2019 14:41:41 +0000 (22:41 +0800)
course/management.php

index 27784d1..492a9f1 100644 (file)
@@ -69,8 +69,11 @@ if ($courseid) {
     $course = null;
     $courseid = null;
     $topchildren = core_course_category::top()->get_children();
+    if (empty($topchildren)) {
+        throw new moodle_exception('cannotviewcategory', 'error');
+    }
     $category = reset($topchildren);
-    $categoryid = $category ? $category->id : 0;
+    $categoryid = $category->id;
     $context = context_coursecat::instance($category->id);
     $url->param('categoryid', $category->id);
 }