From f91261c9fa0eb831f6b16e19f21feab74c0f55ea Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 22 Oct 2021 10:55:54 +0800 Subject: [PATCH] MDL-72882 tool_langimport: Set default language when deleting lang pack * When the language pack being deleted is - the same as the site default language, we must set the site default language to 'en'. - fix the user's current language to the default site language. --- admin/tool/langimport/classes/controller.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/admin/tool/langimport/classes/controller.php b/admin/tool/langimport/classes/controller.php index 82b6c32d1d4..cb38792bd9d 100644 --- a/admin/tool/langimport/classes/controller.php +++ b/admin/tool/langimport/classes/controller.php @@ -124,6 +124,12 @@ class controller { } if ($rm1 or $rm2) { + // Set the default site language to en if the deleted language pack is the default site language. + if ($CFG->lang === $lang) { + set_config('lang', 'en'); + // Fix the user's current language to the default site language. + fix_current_language($CFG->lang); + } $this->info[] = get_string('langpackremoved', 'tool_langimport', $lang); event\langpack_removed::event_with_langcode($lang)->trigger(); return true;