Index: trunk/extensions/ParserFunctions/Expr.php |
— | — | @@ -453,14 +453,24 @@ |
454 | 454 | if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]); |
455 | 455 | $right = array_pop( $stack ); |
456 | 456 | $left = array_pop( $stack ); |
457 | | - // PHP seems to treat "0" and "" appropriately for this to work. |
| 457 | + |
| 458 | + // Fix handling of 0.0, 0.00, etc |
| 459 | + if ($hasBC) { |
| 460 | + $right = bccompWithTolerance( $right, '0' ) != 0; |
| 461 | + $left = bccompWithTolerance( $left, '0' ) != 0; |
| 462 | + } |
| 463 | + |
458 | 464 | $stack[] = ( $left && $right ) ? 1 : 0; |
459 | 465 | break; |
460 | 466 | case EXPR_OR: |
461 | 467 | if ( count( $stack ) < 2 ) throw new ExprError('missing_operand', $this->names[$op]); |
462 | 468 | $right = array_pop( $stack ); |
463 | 469 | $left = array_pop( $stack ); |
464 | | - // PHP seems to treat "0" and "" appropriately for this to work. |
| 470 | + // Fix handling of 0.0, 0.00, etc |
| 471 | + if ($hasBC) { |
| 472 | + $right = bccompWithTolerance( $right, '0' ) != 0; |
| 473 | + $left = bccompWithTolerance( $left, '0' ) != 0; |
| 474 | + } |
465 | 475 | $stack[] = ( $left || $right ) ? 1 : 0; |
466 | 476 | break; |
467 | 477 | case EXPR_EQUALITY: |
— | — | @@ -475,7 +485,10 @@ |
476 | 486 | case EXPR_NOT: |
477 | 487 | if ( count( $stack ) < 1 ) throw new ExprError('missing_operand', $this->names[$op]); |
478 | 488 | $arg = array_pop( $stack ); |
479 | | - // PHP seems to treat "0" and "" appropriately for this to work. |
| 489 | + // Fix handling of 0.0, 0.00, etc |
| 490 | + if ($haveBC) { |
| 491 | + $arg = (bccompWithTolerance( $arg, '0' ) != 0); |
| 492 | + } |
480 | 493 | $stack[] = (!$arg) ? 1 : 0; |
481 | 494 | break; |
482 | 495 | case EXPR_ROUND: |