Page MenuHomePhabricator

ExprModulus2.patch

Authored By
bzimport
Nov 21 2014, 9:19 PM
Size
932 B
Referenced Files
None
Subscribers
None

ExprModulus2.patch

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';

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2567
Default Alt Text
ExprModulus2.patch (932 B)

Event Timeline