Actions
Bug #93346
closedLocalizationUtility::translate throws uncaught exception, if the arguments contains an empty array
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2021-01-22
Due date:
% Done:
0%
Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
$kye = "hallo %s",
$param=[];
sprintf($kye, ...array_values($param));
The code above throws an exception. This exception is uncaught in LocalizationUtility::translate.
I use something like this often. A meaningful exception woul be nice.
$argList = [];
$webTitle = LocalizationUtility::translate(
$item['title'],
'myExtension',
$argList
);
}
Files
Updated by Dieter Porth almost 4 years ago
- Subject changed from LocalizationUtility::translate throws uncaught exception to LocalizationUtility::translate throws uncaught exception, if the arguments contains an empty array
A similiar php-code to the presente example above will found in the method (Line 123-129)
if (is_array($arguments) && $value !== null) {
// This unrolls arguments from $arguments - instead of calling vsprintf which receives arguments as an array.
// The reason is that only sprintf() will return an error message if the number of arguments does not match
// the number of placeholders in the format string. Whereas, vsprintf would silently return nothing.
return sprintf($value, ...array_values($arguments)) ?: sprintf('Error: could not translate key "%s" with value "%s" and %d argument(s)!', $key, $value, count($arguments));
}
Updated by Benni Mack 4 months ago
- Related to Bug #98924: Harden LocalizationUtility with arguments added
Updated by Benni Mack 4 months ago
- Related to Task #96473: Allow ServerRequestInterface in ext:fluid added
Updated by Benni Mack 4 months ago
- Status changed from New to Closed
Hey Dieter,
thanks for the report. Sorry for not responding earlier but this has been fixed via #98924 in v11 already!
Actions