Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 6 comments

2 participants

@doctrinebot

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

@doctrinebot

Comment created by dcousineau:

Maybe serializing instead of running a var_export?

@doctrinebot

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

Comment created by @beberlei:

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

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot

Comment created by dcousineau:

You get a high five, Benjamin!

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.0-RC1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.