[BUGFIX] number_format() expects parameter 1 to be double 78/22978/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 8 Aug 2013 20:49:17 +0000 (22:49 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 8 Aug 2013 20:56:19 +0000 (22:56 +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/22977
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-on: https://review.typo3.org/22978

tests/typo3/sysext/cms/tslib/tslib_contentTest.php
typo3/sysext/cms/tslib/class.tslib_content.php

index 83a4602..e3935ae 100644 (file)
@@ -702,6 +702,13 @@ class tslib_contentTest extends tx_phpunit_testcase {
                                ),
                                '0.80'
                        ),
+                       'testing decimals with input as string' => array(
+                               '0.8',
+                               array(
+                                       'decimals' => 2
+                               ),
+                               '0.80'
+                       ),
                        'testing dec_point' => array(
                                0.8,
                                array(
index 3e8ef14..b2e867c 100644 (file)
@@ -4350,7 +4350,7 @@ class tslib_cObj {
                $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);
        }
 
        /**