-
Bug
-
Resolution: Duplicate
-
Major
-
None
-
2.3.1
-
MOODLE_23_STABLE
If the setting $CFG->navshowmycoursecategories is turned on in Site Administration->Appearance->Navigation, and at least one of the course categories on the top level ($category->parent = 0), is set as hidden, attempting to load any page on the Moodle application will result in the following error message:
"Coding error detected, it must be fixed by a programmer"
|
Upon further investigation, I found that this error was being triggered on line 1134 of file navigationlib.php, in function initialise(). Since this library file is loaded on every request, this error gets triggered every time. Below is the segment of code where the error occurs:
if (!$category->visible)
|
{
|
if (!has_capability('moodle/category:viewhiddencategories', get_context_instance(CONTEXT_COURSECAT, $category->parent))) {
|
$addedcategories[$category->id]->display = false;
|
} else {
|
$addedcategories[$category->id]->hidden = true;
|
}
|
}
|
The exact problem is that the following function call returns bool(false) if $category->parent is set as 0:
get_context_instance(CONTEXT_COURSECAT, $category->parent)
|
This triggers an exception in function has_capability because it expects its 2nd parameter to be of type "context"
- duplicates
-
MDL-34250 Error shown when logging in as a user into a course in a hidden category
-
- Closed
-