Cast Doctrine\ORM\Query\Expr\Comparison::$_rightExpr to integer when false to fix DDC-1683 #297

Closed
wants to merge 2 commits into
from

Projects

None yet

4 participants

@peterjmit
Contributor

Hi

I posted the following bug report http://www.doctrine-project.org/jira/browse/DDC-1683 related to casting false values to strings.

// Doctrine\ORM\Query\Expr\Comparison
public function __construct($leftExpr, $operator, $rightExpr)
{
    $this->_leftExpr  = $leftExpr;
    $this->_operator  = $operator;
    $this->_rightExpr = $rightExpr === false ? (int) $rightExpr : $rightExpr;
}
@asm89
Member
asm89 commented Mar 11, 2012

If you check with === for false you can just return '0' instead of casting the existing expression to an int. I'm just wondering if this problem can occur on more places.

@Ocramius Ocramius commented on an outdated diff Mar 13, 2012
lib/Doctrine/ORM/Query/Expr/Comparison.php
@@ -49,11 +49,11 @@ public function __construct($leftExpr, $operator, $rightExpr)
{
$this->_leftExpr = $leftExpr;
$this->_operator = $operator;
- $this->_rightExpr = $rightExpr;
+ $this->_rightExpr = $rightExpr === false ? (int) $rightExpr : $rightExpr;
@Ocramius
Ocramius Mar 13, 2012 Member

$this->_rightExpr = $rightExpr === false ? 0 : $rightExpr;

@Ocramius
Ocramius Mar 13, 2012 Member

Ah, saw @asm89's comment now :P

@peterjmit
Contributor

Now returning 0 in line with comments

@beberlei
Member
@beberlei beberlei closed this Mar 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment