1

I encountered an issue with Magento 1.9.2.4 and the PHP7 Patch:

If I choose optional DOB and register without DOB, the logfile shows an error:

2018-10-16T09:45:59+00:00 ERR (3): Warning: A non-numeric value encountered  in /var/www/html/magento1924/lib/Zend/Locale/Math/PhpMath.php on line 94
2018-10-16T09:45:59+00:00 ERR (3): Warning: A non-numeric value encountered  in /var/www/html/magento1924/lib/Zend/Locale/Math/PhpMath.php on line 95

To reproduce:

  1. Backend configuration:
    System -> Configuration -> Customers -> Customer Configuration -> Name and Address Options -> Show Date of Birth: "Optional"
  2. Register without submitting a DOB.

I guess the error shows up because magento tries to process the DOB, but it's empty? So I looked at the lines in PhpMath.php and found that only one parameter in the affected function is tested to be empty. So I added the the same lines for the second one (which works for now).

lib/Zend/Locale/Math/PhpMath.php

 public static function Sub($op1, $op2, $scale = null)
 {
     if ($scale === null) {
         $scale     = Zend_Locale_Math_PhpMath::$defaultScale;
         $precision = Zend_Locale_Math_PhpMath::$defaultPrecision;
     } else {
         $precision = pow(10, -$scale);
     }

     if (empty($op1)) {
         $op1 = 0;
     }

 +    if (empty($op2)) {
 +        $op2 = 0;
 +    }
 +    
     $op1  = self::normalize($op1);
     $op2  = self::normalize($op2);
     $result = $op1 - $op2;
     if (is_infinite($result)  or  (abs($result + $op2 - $op1) > $precision)) {
         #require_once 'Zend/Locale/Math/Exception.php';
         throw new Zend_Locale_Math_Exception("subtraction overflow: $op1 - $op2 != $result", $op1, $op2, $result);
     }

     return self::round(self::normalize($result), $scale);
 }

But over all I don't feel very fine changing functions in the ZendFramework part of Magento, considering that for consistency reasons there are several more changes necessary.

Maybe anyone got any other tips?
Thank you for your recommendations!

1

https://github.com/Inchoo/Inchoo_PHP7/issues/125

[...] But I see that PhpMath class isn't used by Zend when bcmath extension is enabled, so enabling bcmath in php could maybe solve the problem?

That did the job for me.

1

It's a PHP version issue.

Few versions support $varibale = ""(Blnk) but the latest PHP version needs $variable = 0 instead of the blank to consider it's value as the numeric.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.