Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-909

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA4
    • Fix Version/s: 2.0-RC1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Debian, PHP 5.3, Doctrine 2.0-BETA4

      Description

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

        Activity

        Hide
        Daniel Cousineau added a comment -

        Maybe serializing instead of running a var_export?

        Show
        Daniel Cousineau added a comment - Maybe serializing instead of running a var_export?
        Hide
        Daniel Cousineau added a comment -

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

        Show
        Daniel Cousineau added a comment - Yeah, changing the var_export($this->_params, true) to serialize($this->_params) has yet to result in the same recursion error.
        Hide
        Benjamin Eberlei added a comment -

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

        Show
        Benjamin Eberlei added a comment - Its unbelievable slow though. I have to change this to retrieve the entity-identifer + name from the UoW
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed
        Hide
        Daniel Cousineau added a comment -

        You get a high five, Benjamin!

        Show
        Daniel Cousineau added a comment - You get a high five, Benjamin!

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Daniel Cousineau
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: