DDC-3317: [GH-1142] func_get_args() call order fix for HHVM bug #4098

Open
opened 2026-01-22 14:35:09 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Sep 22, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of TwoWholeWorms:

Url: https://github.com/doctrine/doctrine2/pull/1142

Message:

This PR fixes bugs in Doctrine\ORM\QueryBuilder where the values provided to method arguments to ::andWhere(), ::orWhere(), ::andHaving(), and ::orHaving() are overwritten by code within the methods in HHVM and PHP7.

After much fun and headscratching in both #doctrine and #hhvm on Freenode, we discovered that in the following code, $where = $this->getDqlPart('where'); overwrites the values stored internally for the $where parameter of the function which is returned by func*get*args():

public function orWhere($where)
{
    $where = $this->getDqlPart('where');
    $args  = func*get*args();
}

This means that instead of $args being set as expected to an array containing the string or object provided to the function, it actually contains the object returned by QueryBuilder::getDqlPart(), which causes all the problems you'd expect it to.

This PR simply swaps the order of the calls so that the function arguments are retrieved via func*get*args() before the $where variable is modified, fixing the problem.

Originally created by @doctrinebot on GitHub (Sep 22, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of TwoWholeWorms: Url: https://github.com/doctrine/doctrine2/pull/1142 Message: This PR fixes bugs in `Doctrine\ORM\QueryBuilder` where the values provided to method arguments to `::andWhere()`, `::orWhere()`, `::andHaving()`, and `::orHaving()` are overwritten by code within the methods in HHVM and PHP7. After much fun and headscratching in both #doctrine and #hhvm on Freenode, we discovered that in the following code, `$where = $this->getDqlPart('where');` overwrites the values stored internally for the `$where` parameter of the function which is returned by `func*get*args()`: ``` public function orWhere($where) { $where = $this->getDqlPart('where'); $args = func*get*args(); } ``` This means that instead of `$args` being set as expected to an array containing the string or object provided to the function, it actually contains the object returned by `QueryBuilder::getDqlPart()`, which causes all the problems you'd expect it to. This PR simply swaps the order of the calls so that the function arguments are retrieved via `func*get*args()` before the `$where` variable is modified, fixing the problem.
admin added the Bug label 2026-01-22 14:35:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4098