createQueryBuilder, when using php PM "parameters" are not cleared #6132

Closed
opened 2026-01-22 15:27:16 +01:00 by admin · 3 comments
Owner

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.

Q A
BC Break no
Version v2.6.3

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.

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. | Q | A |------------ | ------ | BC Break | no | Version | v2.6.3 #### 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.
admin added the BugInvalid labels 2026-01-22 15:27:16 +01:00
admin closed this issue 2026-01-22 15:27:16 +01:00
Author
Owner

@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)

@Ocramius commented on GitHub (Dec 14, 2018): Doesn't seem to be related to ORM, since this is the implementation of `createQueryBuilder`: https://github.com/doctrine/doctrine2/blob/434820973cadf2da2d66e7184be370084cc32ca8/lib/Doctrine/ORM/EntityRepository.php#L71-L84 https://github.com/doctrine/doctrine2/blob/434820973cadf2da2d66e7184be370084cc32ca8/lib/Doctrine/ORM/EntityManager.php#L331-L337
Author
Owner

@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 :/

@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 :/
Author
Owner

@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.

@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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6132