Skip to content

Commit

Permalink
[BUGFIX] Avoid associative array to be used in LocalizationUtility
Browse files Browse the repository at this point in the history
On using associative array in LocalizationUtility which is e.g. used
by Fluid's TranslateViewHelper, the error Cannot unpack array with
string keys is thrown. The reason is that sprintf($value, ...$arguments)
cannot be used with $arguments being an associative array.

Resolves: #84149
Releases: master
Change-Id: Ifb60338bcf9095954969221cf08bd7e3d141ecc2
Reviewed-on: https://review.typo3.org/56024
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
ohader authored and andreaskienast committed Mar 6, 2018
1 parent 7e00cef commit 60a68a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Expand Up @@ -127,7 +127,7 @@ public static function translate($key, $extensionName = null, $arguments = 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, ...$arguments) ?: sprintf('Error: could not translate key "%s" with value "%s" and %d argument(s)!', $key, $value, count($arguments));
return sprintf($value, ...array_values($arguments)) ?: sprintf('Error: could not translate key "%s" with value "%s" and %d argument(s)!', $key, $value, count($arguments));
}
return $value;
}
Expand Down
@@ -1,4 +1,4 @@
<p><f:translate key="dependencyCheck.headline" arguments="{extensionKey: extension.extensionKey}" />:</p>
<p><f:translate key="dependencyCheck.headline" arguments="{0: extension.extensionKey}" />:</p>
<ul>
<f:for each="{unresolvedDependencies}" key="key" as="messages">
<f:if condition="{key} == {extension.extensionKey}">
Expand All @@ -19,4 +19,4 @@
</li>
</f:if>
</f:for>
</ul>
</ul>

0 comments on commit 60a68a5

Please sign in to comment.