MDL-38345 Prevent undefined CFG leading to DB error.
It seems that MDL-32975, no matter a version bump was done, leads to the $CFG->navsortmycoursessort setting undefined sometimes. And that ends with an error visiting the /my page. This just ensures a safe default if the setting is undefined/empty.
This commit is contained in:
@@ -2584,6 +2584,10 @@ class global_navigation extends navigation_node {
|
||||
protected function load_courses_enrolled() {
|
||||
global $CFG, $DB;
|
||||
$sortorder = 'visible DESC';
|
||||
// Prevent undefined $CFG->navsortmycoursessort errors.
|
||||
if (empty($CFG->navsortmycoursessort)) {
|
||||
$CFG->navsortmycoursessort = 'sortorder';
|
||||
}
|
||||
// Append the chosen sortorder.
|
||||
$sortorder = $sortorder . ',' . $CFG->navsortmycoursessort . ' ASC';
|
||||
$courses = enrol_get_my_courses(null, $sortorder);
|
||||
|
||||
Reference in New Issue
Block a user