[BUGFIX] number_format() expects parameter 1 to be double 36/22936/4
authorWouter Wolters <typo3@wouterwolters.nl>
Wed, 7 Aug 2013 17:46:54 +0000 (19:46 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 8 Aug 2013 20:27:35 +0000 (22:27 +0200)
In stdWrap function numberFormat $content is a string.
Make sure this is a float value when it is passed into
PHP function number_format.

Change-Id: If4a98ae8238264f94f771c997fbe6cac98311912
Resolves: #50868
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Reviewed-on: https://review.typo3.org/22936
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index aca331b..6fc75eb 100644 (file)
@@ -4573,7 +4573,7 @@ class ContentObjectRenderer {
                $decimals = isset($conf['decimals.']) ? $this->stdWrap($conf['decimals'], $conf['decimals.']) : $conf['decimals'];
                $dec_point = isset($conf['dec_point.']) ? $this->stdWrap($conf['dec_point'], $conf['dec_point.']) : $conf['dec_point'];
                $thousands_sep = isset($conf['thousands_sep.']) ? $this->stdWrap($conf['thousands_sep'], $conf['thousands_sep.']) : $conf['thousands_sep'];
-               return number_format($content, $decimals, $dec_point, $thousands_sep);
+               return number_format(floatval($content), $decimals, $dec_point, $thousands_sep);
        }
 
        /**
index 142f8ed..13b6727 100644 (file)
@@ -986,6 +986,13 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                ),
                                '0.80'
                        ),
+                       'testing decimals with input as string' => array(
+                               '0.8',
+                               array(
+                                       'decimals' => 2
+                               ),
+                               '0.80'
+                       ),
                        'testing dec_point' => array(
                                0.8,
                                array(