From 9bbaee54513d3a40f20fa4f64a9be036db2ff862 Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Sat, 6 Dec 2025 20:05:58 +0700 Subject: [PATCH 1/2] Prevent error when language file cache is broken --- libraries/src/Language/LanguageHelper.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libraries/src/Language/LanguageHelper.php b/libraries/src/Language/LanguageHelper.php index baa6ae58191f9..3fcc0fc0434f1 100644 --- a/libraries/src/Language/LanguageHelper.php +++ b/libraries/src/Language/LanguageHelper.php @@ -454,7 +454,18 @@ public static function parseIniFile($fileName, $debug = false) $cacheFile = JPATH_CACHE . '/language/' . ltrim(str_replace([JPATH_ROOT, '/'], ['', '-'], $fileName), '-') . '.' . filemtime($fileName) . '.php'; if (is_file($cacheFile)) { - return include $cacheFile; + $result = include $cacheFile; + + if (\is_array($result)) { + return $result; + } else { + // When $result is not an array, the cache file is corrupted, we will delete it and have it regenerated + try { + File::delete($cacheFile); + } catch (FilesystemException $e) { + // We ignore the error, as the file is for caching only. + } + } } // This was required for https://github.com/joomla/joomla-cms/issues/17198 but not sure what server setup From cada051f6f0441b44a5055d7b7138a1a51aa45cb Mon Sep 17 00:00:00 2001 From: Tuan Pham Ngoc Date: Sat, 6 Dec 2025 20:21:51 +0700 Subject: [PATCH 2/2] CS --- libraries/src/Language/LanguageHelper.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/src/Language/LanguageHelper.php b/libraries/src/Language/LanguageHelper.php index 3fcc0fc0434f1..0dc660af79dfe 100644 --- a/libraries/src/Language/LanguageHelper.php +++ b/libraries/src/Language/LanguageHelper.php @@ -458,13 +458,13 @@ public static function parseIniFile($fileName, $debug = false) if (\is_array($result)) { return $result; - } else { - // When $result is not an array, the cache file is corrupted, we will delete it and have it regenerated - try { - File::delete($cacheFile); - } catch (FilesystemException $e) { - // We ignore the error, as the file is for caching only. - } + } + + // When $result is not an array, the cache file is corrupted, we will delete it and have it regenerated + try { + File::delete($cacheFile); + } catch (FilesystemException $e) { + // We ignore the error, as the file is for caching only. } }