Index: Expr.php =================================================================== --- Expr.php (revision 14818) +++ Expr.php (working copy) @@ -86,6 +86,7 @@ 'div' => EXPR_DIVIDE ); + var $_bcmath_enabled; /** * Add expression messages to the message cache @@ -353,7 +354,19 @@ $right = array_pop( $stack ); $left = array_pop( $stack ); if ( $right == 0 ) return 'division_by_zero'; - $stack[] = $left % $right; + + // check if BCMath is enabled and cache the result + if ($this->_bcmath_enabled === null) { + $this->_bcmath_enabled = extension_loaded('bcmath'); + } + + // call BCMath if it's enabled to fix Bug 6356 + if ($this->_bcmath_enabled) { + $stack[] = bcmod($left, $right); + } else + $stack[] = $left % $right; + } + break; case EXPR_PLUS: if ( count( $stack ) < 2 ) return 'missing_operand';