Bug #85741

Bugfix for MathExpressionNode.php

Added by Daxboeck no-lastname-given 6 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Start date:
2018-08-03
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

    /**
     * @param integer|float $left
     * @param string $operator
     * @param integer|float $right
     * @return integer|float
     */
    protected static function evaluateOperation($left, $operator, $right)
    {
        if ($operator === '%') {
            return (float)$left % (float)$right;
        } elseif ($operator === '-') {
            return (float)$left - (float)$right;
        } elseif ($operator === '+') {
            return (float)$left + (float)$right;
        } elseif ($operator === '*') {
            return (float)$left * (float)$right;
        } elseif ($operator === '/') {
            return (integer) $right !== 0 ? (float)$left / (float)$right : 0;
        } elseif ($operator === '^') {
            return pow((float)$left, (float)$right);
        }
        return 0;
    }

Related issues

Duplicates TYPO3 Core - Bug #85604: PHP warning when doing math in Fluid Closed 2018-07-20

History

#1 Updated by Georg Ringer 6 months ago

  • Description updated (diff)
  • Status changed from New to Needs Feedback

please add some more information: how to reproduce? what do you expect, what is the current outcome?

#2 Updated by Daxboeck no-lastname-given 6 months ago

I had to add the type declarations (float) to avoid warnings when I used Math in my Fluid templates.

e.g. {dimensions.height*1.5} did cause a PHP warning in that file (MathExpressionNode.php), which the above code replacement fixes.

#3 Updated by Susanne Moog 4 months ago

  • Target version changed from 8.7.19 to Candidate for patchlevel

#4 Updated by Wouter Wolters 2 months ago

  • Duplicates Bug #85604: PHP warning when doing math in Fluid added

#5 Updated by Wouter Wolters 2 months ago

  • Status changed from Needs Feedback to Closed

Closing this ticket as duplicate of #85604

Also available in: Atom PDF