[BUGFIX] Avoid associative array to be used in LocalizationUtility 24/56024/2
authorOliver Hader <oliver@typo3.org>
Tue, 6 Mar 2018 15:17:46 +0000 (16:17 +0100)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Tue, 6 Mar 2018 19:10:54 +0000 (20:10 +0100)
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>
typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php
typo3/sysext/extensionmanager/Resources/Private/Partials/List/UnresolvedDependencies.html

index 1f00f33..3c748ce 100644 (file)
@@ -127,7 +127,7 @@ class LocalizationUtility
             // 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;
     }
index 8434b4c..f2ecf2d 100644 (file)
@@ -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}">
@@ -19,4 +19,4 @@
                        </li>
                </f:if>
        </f:for>
-</ul>
\ No newline at end of file
+</ul>