View Issue Details

IDProjectCategoryView StatusLast Update
0007074OXID eShop (all versions)4.05. Performancepublic2020-01-21 09:08
Reportertimwetter 
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version6.2.0-rc.1 
Target VersionFixed in Version 
Summary0007074: workaround for #36008 bug in php in file Utils.php wihtout phpversion check
Descriptionthe workaround for php bug #36008 is obsolet for phpversion >= 5.3.
it may be better for performance to check if someone still uses php < 5.3 and then do the workaround!?


    /**
     * Rounds the value to currency cents. This method does NOT format the number.
     *
     * @param string $sVal the value that should be rounded
     * @param object $oCur Currency Object
     *
     * @return float
     */
    public function fRound($sVal, $oCur = null)
    {
        startProfile('fround');

        //cached currency precision, this saves about 1% of execution time
        $iCurPrecision = $this->_iCurPrecision;

        if (is_null($iCurPrecision)) {
            if (!$oCur) {
                $oCur = $this->getConfig()->getActShopCurrencyObject();
            }

            $iCurPrecision = $oCur->decimal;
            $this->_iCurPrecision = $iCurPrecision;
        }

        // if < 5.3.x this is a workaround for #36008 bug in php - incorrect round() & number_format() result (R)
++ $sVal = (float) $sVal;
++ if (phpversion() < '5.3') {
            static $dprez = null;
            if (!$dprez) {
                $prez = @ini_get("precision");
                if (!$prez || $prez > 12) {
                    $prez = 12;
                }
                $dprez = pow(10, -$prez);
            }

++ stopProfile('fround');
++ return round($sVal + $dprez * ($sVal >= 0 ? 1 : -1), $iCurPrecision);
++ }
        stopProfile('fround');

-- $sVal = (float) $sVal;
        return round($sVal, $iCurPrecision);
    }
TagsNo tags attached.
ThemeNot defined
BrowserNot defined
PHP VersionNot defined
Database VersionNot defined

Activities

florian.engelhardt

2020-01-21 08:41

manager   ~0013093

Hey Tim,

looks reasonable to me, would you mind opening a pull request on our GitHub Repository?
https://github.com/OXID-eSales/oxideshop_ce/blob/b-6.x/source/Core/Utils.php

Kind regards
Florian

QA

2020-01-21 09:06

administrator   ~0013094

-MK

QA

2020-01-21 09:08

administrator   ~0013095

Fixed wrong status. -MK