Issue Bug Closed

#50868stdWrap.numberFormat (tslib_cObj->numberFormat) fills database table sys_log

Christian Finkemeier 08/07/13, 12:30 updated 10/02/18, 12:12

Description

I am using the stdWrap.numberFormat very often. But it has a negative impact on my databases.

Every time i use the feature a sys_log entry is created:

Core: Error handler (FE): PHP Warning: number_format() expects parameter 1 to be double,
string given in typo3/sysext/cms/tslib/class.tslib_content.php line 4353

PHP expects the first parameter to be float but the main stdWrap function always passes a string value for the $content variable.

It would be very easy to correct this bug by changing one line:

--- typo3/sysext/cms/tslib/class.tslib_content.php
+++ typo3/sysext/cms/tslib/class.tslib_content.php
@@ -4343,12 +4343,12 @@ class tslib_cObj
    function numberFormat($content, $conf) {
        $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);
    }

best regards
Christian

Reviews 5