Revert "[BUGFIX] config.locale_all should format floating point values" 41/47841/2
authorNicole Cordes <typo3@cordes.co>
Thu, 21 Apr 2016 15:22:58 +0000 (17:22 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 24 Apr 2016 14:01:09 +0000 (16:01 +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/47841
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index 15142ba..6c109db 100644 (file)
@@ -2814,8 +2814,14 @@ class TypoScriptFrontendController
     {
         // Setting locale
         if ($this->config['config']['locale_all']) {
-            $locale = setlocale(LC_ALL, $this->config['config']['locale_all']);
+            // 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, $this->config['config']['locale_all']);
             if ($locale) {
+                setlocale(LC_CTYPE, $this->config['config']['locale_all']);
+                setlocale(LC_MONETARY, $this->config['config']['locale_all']);
+                setlocale(LC_TIME, $this->config['config']['locale_all']);
                 $this->localeCharset = $this->csConvObj->get_locale_charset($this->config['config']['locale_all']);
             } else {
                 $this->getTimeTracker()->setTSlogMessage('Locale "' . htmlspecialchars($this->config['config']['locale_all']) . '" not found.', 3);