mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
createQueryBuilder, when using php PM "parameters" are not cleared #6132
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jc-src on GitHub (Dec 13, 2018).
Originally assigned to: @Ocramius on GitHub.
Bug Report
Using ReactPhp/Php-pm Process Manager, in memory php process management, the action of repository->createQueryBuilder do not "reset" the parameters keeping them for the next query.
Despite using
return new QueryBuilder($this);
The constructor is kept in memory and parameters are still kept with previous values.
Summary
On create QueryBuilder if using php-pm the Parameters are not cleared for next query.
The work around is to manually set the params empty: $builder->setParameters([])
Current behavior
Mismatch of "settet values": Server error 500: Too many parameters: the query defines 1 parameters and you bound 2
How to reproduce
Using a php process manager like ReactPhp or php-pm run a query wwhere you set a parameter to a specific key and just execute it again.
Here is the output of a getSQL():
SELECT e0_.id AS id_0, e0_.name AS name_1
FROM event e0_
LEFT JOIN property_version p1_ ON e0_.version_id = p1_.id AND ((p1_.account_id = 1)) AND (p1_.deleted_at IS NULL)
WHERE (p1_.version IS NULL AND p1_.property_id = ?) AND ((e0_.account_id = 1)) AND (e0_.deleted_at IS NULL) GROUP BY e0_.id ORDER BY e0_.name ASC LIMIT 200 OFFSET 0
set params are: {"version_property4":"1","version_property6":"1"}
Expected behavior
Parameters should be reset/cleared on creating a new QueryBuilder, even using a PM.
@Ocramius commented on GitHub (Dec 14, 2018):
Doesn't seem to be related to ORM, since this is the implementation of
createQueryBuilder:434820973c/lib/Doctrine/ORM/EntityRepository.php (L71-L84)434820973c/lib/Doctrine/ORM/EntityManager.php (L331-L337)@jc-src commented on GitHub (Dec 14, 2018):
Sorry, after investigating and running test we found the error, we where extending some Expression Builders and found out that declaring a private variable in a Abstract class was not cleared after each request.
I close the issue but there is still something not working correctly when using PM.
The query builder params are not cleared fully and keeps adding up numbers.
After each query I see the Integer raise...
"version_property19":"1"
"version_property20":"1"
"version_property21":"1"
"version_property22":"1"
...
I wonder when it will break :/
@Ocramius commented on GitHub (Dec 14, 2018):
@jc-src if it's not an ORM issue, then it needs testing on your side first, sorry.