From a75dfd6f3364d24ed2414716bc3e63b8f180f014 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 7 Mar 2013 10:21:03 +0100 Subject: [PATCH] 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. --- lib/navigationlib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index b2fdc65a7c1..432a120dad6 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -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);