DDC-909: Doctrine 2 AbstractQuery:: _getResultCacheId() fails when an Entity instance is used as a param (recursive references and var_export don't mix) #1131

Closed
opened 2026-01-22 13:03:12 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 2, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user dcousineau:

In the AbstractQuery::_getResultCacheId() function the following line generates the MD5 hash key:

            return md5(implode(";", (array)$sql) . var*export($this->*params, true) .
                var*export($this->_hints, true)."&hydrationMode=".$this->*hydrationMode);

The issue is the use of var*export($this->*params, true); fails when one of the params is an instance of an Entity (which usually have recursive references).

To be honest I really don't know what solution there would be internally, if doctrine were to extend the proxy class to provide a "getIdentifier" or if the _getResultCacheId() could grab the identification of the Entity we could avoid this.

However beyond that potential idea really probably the best thing is to throw a giant warning text in the manual saying "if your'e using entities as parameters manually set your cache ids".

Originally created by @doctrinebot on GitHub (Dec 2, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user dcousineau: In the AbstractQuery::_getResultCacheId() function the following line generates the MD5 hash key: ``` return md5(implode(";", (array)$sql) . var*export($this->*params, true) . var*export($this->_hints, true)."&hydrationMode=".$this->*hydrationMode); ``` The issue is the use of `var*export($this->*params, true);` fails when one of the params is an instance of an Entity (which usually have recursive references). To be honest I really don't know what solution there would be internally, if doctrine were to extend the proxy class to provide a "getIdentifier" or if the _getResultCacheId() could grab the identification of the Entity we could avoid this. However beyond that potential idea really probably the best thing is to throw a giant warning text in the manual saying "if your'e using entities as parameters manually set your cache ids".
admin added the Bug label 2026-01-22 13:03:12 +01:00
admin closed this issue 2026-01-22 13:03:14 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 2, 2010):

Comment created by dcousineau:

Maybe serializing instead of running a var_export?

@doctrinebot commented on GitHub (Dec 2, 2010): Comment created by dcousineau: Maybe serializing instead of running a var_export?
Author
Owner

@doctrinebot commented on GitHub (Dec 2, 2010):

Comment created by dcousineau:

Yeah, changing the var*export($this->_params, true) to serialize($this->*params) has yet to result in the same recursion error.

@doctrinebot commented on GitHub (Dec 2, 2010): Comment created by dcousineau: Yeah, changing the `var*export($this->_params, true)` to `serialize($this->*params)` has yet to result in the same recursion error.
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2010):

Comment created by @beberlei:

Its unbelievable slow though. I have to change this to retrieve the entity-identifer + name from the UoW

@doctrinebot commented on GitHub (Dec 3, 2010): Comment created by @beberlei: Its unbelievable slow though. I have to change this to retrieve the entity-identifer + name from the UoW
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2010):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Dec 3, 2010): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 3, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 3, 2010):

Comment created by dcousineau:

You get a high five, Benjamin!

@doctrinebot commented on GitHub (Dec 3, 2010): Comment created by dcousineau: You get a high five, Benjamin!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1131