Revert "[BUGFIX] config.locale_all should format floating point values" 28/47828/4
authorNicole Cordes <typo3@cordes.co>
Wed, 20 Apr 2016 20:59:04 +0000 (22:59 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Thu, 21 Apr 2016 15:21:42 +0000 (17:21 +0200)
PHP 7 still has the problem converting a float to a string is
locale-aware (https://bugs.php.net/bug.php?id=53711). This means a float
might be returned with a comma as decimal point. This is not intended
and breaks value conversions so this patch restores the old behavior.

This reverts commit 7cbef93a8698347bc55e364fb7ffa3e796b733ec.

Resolves: #75780
Resolves: #75825
Releases: master, 7.6
Change-Id: I83a443617e50a86b0297c49887e94f226104c910
Reviewed-on: https://review.typo3.org/47828
Reviewed-by: Stephan Großberndt <stephan@grossberndt.de>
Tested-by: Stephan Großberndt <stephan@grossberndt.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index dc7b329..34dfe67 100644 (file)
@@ -2734,8 +2734,15 @@ class TypoScriptFrontendController
         // Setting locale
         if ($this->config['config']['locale_all']) {
             $availableLocales = GeneralUtility::trimExplode(',', $this->config['config']['locale_all'], true);
-            $locale = setlocale(LC_ALL, ...$availableLocales);
-            if (!$locale) {
+            // If LC_NUMERIC is set e.g. to 'de_DE' PHP parses float values locale-aware resulting in strings with comma
+            // as decimal point which causes problems with value conversions - so we set all locale types except LC_NUMERIC
+            // @see https://bugs.php.net/bug.php?id=53711
+            $locale = setlocale(LC_COLLATE, ...$availableLocales);
+            if ($locale) {
+                setlocale(LC_CTYPE, ...$availableLocales);
+                setlocale(LC_MONETARY, ...$availableLocales);
+                setlocale(LC_TIME, ...$availableLocales);
+            } else {
                 $this->getTimeTracker()->setTSlogMessage('Locale "' . htmlspecialchars($this->config['config']['locale_all']) . '" not found.', 3);
             }
         }