mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Issue #5465 Fixed fallback. Added user error warning for missing LANs.
This commit is contained in:
@@ -1999,8 +1999,8 @@ class error_handler
|
|||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->label = array(E_NOTICE => "Notice", E_WARNING => "Warning", E_DEPRECATED => "Deprecated");
|
$this->label = array(E_NOTICE => "Notice", E_USER_NOTICE => "Notice", E_WARNING => "Warning",E_USER_WARNING => "Warning", E_DEPRECATED => "Deprecated");
|
||||||
$this->color = array(E_NOTICE=> 'info', E_WARNING=>'warning', E_DEPRECATED => 'danger');
|
$this->color = array(E_NOTICE=> 'info', E_USER_NOTICE=> 'info' , E_WARNING=>'warning',E_USER_WARNING => "warning", E_DEPRECATED => 'danger');
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '8.4', '<'))
|
if (version_compare(PHP_VERSION, '8.4', '<'))
|
||||||
{
|
{
|
||||||
@@ -2099,6 +2099,7 @@ class error_handler
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case E_NOTICE:
|
case E_NOTICE:
|
||||||
|
case E_USER_NOTICE:
|
||||||
// case E_STRICT:
|
// case E_STRICT:
|
||||||
|
|
||||||
if ($startup_error || $this->deftrue('E107_DBG_ALLERRORS') || $this->deftrue('E107_DBG_ERRBACKTRACE'))
|
if ($startup_error || $this->deftrue('E107_DBG_ALLERRORS') || $this->deftrue('E107_DBG_ERRBACKTRACE'))
|
||||||
@@ -2107,6 +2108,7 @@ class error_handler
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case E_WARNING:
|
case E_WARNING:
|
||||||
|
case E_USER_WARNING:
|
||||||
if ($startup_error || $this->deftrue('E107_DBG_BASIC') || $this->deftrue('E107_DBG_ERRBACKTRACE'))
|
if ($startup_error || $this->deftrue('E107_DBG_BASIC') || $this->deftrue('E107_DBG_ERRBACKTRACE'))
|
||||||
{
|
{
|
||||||
$this->addError($type, $message,$line,$file);
|
$this->addError($type, $message,$line,$file);
|
||||||
|
@@ -3737,46 +3737,44 @@ class e107
|
|||||||
public static function includeLan($path, $force = false, $lang = '')
|
public static function includeLan($path, $force = false, $lang = '')
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!is_readable($path))
|
|
||||||
{
|
|
||||||
if((e_LANGUAGE === 'English') || self::getPref('noLanguageSubs'))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
self::getDebug()->log("Couldn't load language file: " . $path);
|
|
||||||
|
|
||||||
$path = str_replace(e_LANGUAGE, 'English', $path);
|
|
||||||
|
|
||||||
self::getDebug()->log("Attempts to load default language file: " . $path);
|
|
||||||
|
|
||||||
if(!is_readable($path))
|
|
||||||
{
|
|
||||||
self::getDebug()->log("Couldn't load default language file: " . $path);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$adminLanguage = self::getPref('adminlanguage');
|
$adminLanguage = self::getPref('adminlanguage');
|
||||||
|
|
||||||
if(e_ADMIN_AREA && vartrue($adminLanguage))
|
if(deftrue('e_ADMIN_AREA') && !empty($adminLanguage))
|
||||||
{
|
{
|
||||||
$path = str_replace(e_LANGUAGE, $adminLanguage, $path);
|
$path = str_replace(e_LANGUAGE, $adminLanguage, $path);
|
||||||
|
$lang = $adminLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(is_readable($path))
|
||||||
|
{
|
||||||
$ret = ($force) ? include($path) : include_once($path);
|
$ret = ($force) ? include($path) : include_once($path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine the language: use $lang if provided, otherwise fall back to e_LANGUAGE or 'English'
|
// Determine the language: use $lang if provided, otherwise fall back to e_LANGUAGE or 'English'
|
||||||
$effectiveLang = $lang ?: (defined('e_LANGUAGE') ? e_LANGUAGE : 'English');
|
if ($lang)
|
||||||
|
{
|
||||||
|
$effectiveLang = $lang;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$effectiveLang = defined('e_LANGUAGE') ? e_LANGUAGE : 'English';
|
||||||
|
}
|
||||||
|
|
||||||
// If the included file returns an array, process it with the new system
|
|
||||||
if(is_array($ret))
|
if(is_array($ret))
|
||||||
{
|
{
|
||||||
self::includeLanArray($ret, $path, $effectiveLang);
|
self::includeLanArray($ret, $path, $effectiveLang);
|
||||||
|
|
||||||
return true; // New-style success indicator
|
return true; // New-style success indicator
|
||||||
}
|
}
|
||||||
|
elseif($effectiveLang !== 'English' && !self::getPref('noLanguageSubs', false)) // Fallback
|
||||||
|
{
|
||||||
|
self::includeLanArray(null, $path, $effectiveLang);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Old-style behavior: return the include result or empty string if unset
|
// Old-style behavior: return the include result or empty string if unset
|
||||||
return (isset($ret)) ? $ret : "";
|
return (isset($ret)) ? $ret : "";
|
||||||
@@ -3802,6 +3800,8 @@ class e107
|
|||||||
static $english_terms = []; // Cache English terms by file key
|
static $english_terms = []; // Cache English terms by file key
|
||||||
|
|
||||||
// Define constants from the current language’s array first
|
// Define constants from the current language’s array first
|
||||||
|
if(!empty($terms) && is_array($terms))
|
||||||
|
{
|
||||||
foreach($terms as $const => $value)
|
foreach($terms as $const => $value)
|
||||||
{
|
{
|
||||||
if(!defined($const))
|
if(!defined($const))
|
||||||
@@ -3809,16 +3809,13 @@ class e107
|
|||||||
define($const, $value);
|
define($const, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Load English fallback if not cached and not already English
|
// Load English fallback if not cached and not already English
|
||||||
if($lang !== 'English' && !isset($english_terms[$file_key]))
|
if($lang !== 'English' && !isset($english_terms[$file_key]))
|
||||||
{
|
{
|
||||||
$english_path = preg_replace(
|
$english_path = str_replace($lang, 'English', $path);
|
||||||
"#/{$lang}/([^/]+)$#i",
|
|
||||||
'/English/$1',
|
if(is_readable($english_path))
|
||||||
$path
|
|
||||||
);
|
|
||||||
if(file_exists($english_path))
|
|
||||||
{
|
{
|
||||||
$english_terms[$file_key] = include($english_path);
|
$english_terms[$file_key] = include($english_path);
|
||||||
if(!is_array($english_terms[$file_key]))
|
if(!is_array($english_terms[$file_key]))
|
||||||
@@ -3828,12 +3825,13 @@ class e107
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self::getDebug()->log("No English fallback found for: " . $english_path);
|
trigger_error("No English fallback found for: $english_path", E_USER_WARNING);
|
||||||
$english_terms[$file_key] = [];
|
$english_terms[$file_key] = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For non-English, define English constants only if not already defined
|
// For non-English, define English constants only if not already defined
|
||||||
|
|
||||||
if($lang !== 'English' && !empty($english_terms[$file_key]))
|
if($lang !== 'English' && !empty($english_terms[$file_key]))
|
||||||
{
|
{
|
||||||
foreach($english_terms[$file_key] as $const => $english_value)
|
foreach($english_terms[$file_key] as $const => $english_value)
|
||||||
@@ -3841,6 +3839,7 @@ class e107
|
|||||||
if(!defined($const))
|
if(!defined($const))
|
||||||
{
|
{
|
||||||
define($const, $english_value);
|
define($const, $english_value);
|
||||||
|
trigger_error("Missing $lang constant: $const in $path", E_USER_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,4 +7,4 @@ modules:
|
|||||||
enabled:
|
enabled:
|
||||||
- Asserts
|
- Asserts
|
||||||
- \Helper\Unit
|
- \Helper\Unit
|
||||||
|
error_level: "E_ALL & ~E_USER_WARNING"
|
||||||
|
Reference in New Issue
Block a user