mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
catch exception in _try_lang to NOT generate a Fatal error by throwing another exception in the handler
This commit is contained in:
parent
b998382cd2
commit
352e05d8e8
@ -19,7 +19,7 @@ use EGroupware\Api;
|
||||
* This function is useful for exception handlers or early stages of the initialisation of the egw object,
|
||||
* as calling lang would try to load the translations, evtl. cause more errors, eg. because there's no db-connection.
|
||||
*
|
||||
* @param string $key message in englich with %1, %2, ... placeholders
|
||||
* @param string $key message in English with %1, %2, ... placeholders
|
||||
* @param string $vars =null multiple values to replace the placeholders
|
||||
* @return string translated message with placeholders replaced
|
||||
*/
|
||||
@ -32,7 +32,16 @@ function try_lang($key,$vars=null)
|
||||
$vars = func_get_args();
|
||||
array_shift($vars); // remove $key
|
||||
}
|
||||
return class_exists('EGroupware\Api\Translation',false) ? Api\Translation::translate($key,$vars) : str_replace($varnames,$vars,$key);
|
||||
if (class_exists('EGroupware\Api\Translation',false))
|
||||
{
|
||||
try {
|
||||
return Api\Translation::translate($key, $vars);
|
||||
}
|
||||
catch (\Throwable $e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return str_replace($varnames,$vars,$key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,4 +209,4 @@ class egw_exception_warning extends Exception {}
|
||||
|
||||
// install our error-handler only for catchable fatal errors and warnings
|
||||
// following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING
|
||||
set_error_handler('egw_error_handler', E_RECOVERABLE_ERROR|E_USER_ERROR|E_WARNING|E_USER_WARNING);
|
||||
set_error_handler('egw_error_handler', E_RECOVERABLE_ERROR|E_USER_ERROR|E_WARNING|E_USER_WARNING);
|
Loading…
Reference in New Issue
Block a user