From 38f5c818cbd53ba44f47573712b42562b1451241 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Fri, 24 Mar 2023 12:42:53 +0100 Subject: [PATCH] MDL-77735 core: Check $CFG->lang isset In some cases, $CFG->lang might not be set, and this is causing a Notice to be displayed when, for instance, database connection fails. This patch should fix this case. --- lib/weblib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/weblib.php b/lib/weblib.php index eaf6cbba0a3..e93b369e321 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2275,7 +2275,7 @@ function get_html_lang($dir = false) { global $CFG; $currentlang = current_language(); - if ($currentlang !== $CFG->lang && !get_string_manager()->translation_exists($currentlang)) { + if (isset($CFG->lang) && $currentlang !== $CFG->lang && !get_string_manager()->translation_exists($currentlang)) { // Use the default site language when the current language is not available. $currentlang = $CFG->lang; // Fix the current language.