From acfc658b4e6ffa422771fbc019435471dc6a60c3 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 4 Jun 2012 11:40:55 +0200 Subject: [PATCH] BUGFIX Fail silently in _t() legacy mode when using sprintf(), to avoid outdated translations breaking with a fatal error (e.g. CMSMain.ACCESS changed from two to one usage of {title}, which isn't changed yet in most languages). Slight performance overhead, but acceptable since its legacy usage only --- i18n/i18n.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/i18n/i18n.php b/i18n/i18n.php index a8bd76285..d16141e8a 100644 --- a/i18n/i18n.php +++ b/i18n/i18n.php @@ -1524,7 +1524,9 @@ class i18n extends Object implements TemplateGlobalProvider { if(!preg_match($regex, $returnValue)) { // Legacy mode: If no injection placeholders are found, // replace sprintf placeholders in fixed order. - $returnValue = vsprintf($returnValue, array_values($injectionArray)); + // Fail silently in case the translation is outdated + $replaced = @vsprintf($returnValue, array_values($injectionArray)); + if($replaced) $returnValue = $replaced; } else if(!ArrayLib::is_associative($injectionArray)) { // Legacy mode: If injection placeholders are found, // but parameters are passed without names, replace them in fixed order.