Doctrine 1
  1. Doctrine 1
  2. DC-857

postHydrate not called for One to One relations, when ATTR_HYDRATE_OVERWRITE == false, and the record is cached in the table's identityMap

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:
      All

      Description

      When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

      This is due to this line.

       
      } else if ( ! isset($prev[$parent][$relationAlias])) {
      

      ...which will always evaluate to false, and postHydrate will ever be called, as the record has been pulled from the table cache here

      1. DC857.patch
        1 kB
        Ben Davies
      2. DC857TestCase.php
        2 kB
        Ben Davies

        Activity

        Ben Davies created issue -
        Hide
        Ben Davies added a comment -

        Test case attached.

        Show
        Ben Davies added a comment - Test case attached.
        Ben Davies made changes -
        Field Original Value New Value
        Attachment DC857TestCase.php [ 10770 ]
        Hide
        Ben Davies added a comment - - edited

        There needs to be some kind of caching on the pre/postHydrate calls, which is done throughout the Doctrine_Hydrator_Graph, except for when the relation is one-to-one.
        This is done just above, for relations that are not one-to-one.

        Unfortunately, I couldn't work out how to implement it for one-to-one.
        Probably a simple fix for someone familiar with the code

        Show
        Ben Davies added a comment - - edited There needs to be some kind of caching on the pre/postHydrate calls, which is done throughout the Doctrine_Hydrator_Graph, except for when the relation is one-to-one. This is done just above , for relations that are not one-to-one. Unfortunately, I couldn't work out how to implement it for one-to-one. Probably a simple fix for someone familiar with the code
        Ben Davies made changes -
        Description When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        isset($prev[$parent][$relationAlias])
        {code}

        ...will always evaluate to true (and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Table.php#L1845]
        When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        isset($prev[$parent][$relationAlias])
        {code}

        ...which will always evaluate to true (and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Table.php#L1845]
        Ben Davies made changes -
        Description When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        isset($prev[$parent][$relationAlias])
        {code}

        ...which will always evaluate to true (and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Table.php#L1845]
        When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        } else if ( ! isset($prev[$parent][$relationAlias])) {
        {code}

        ...which will always evaluate to true (and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Table.php#L1845]
        Ben Davies made changes -
        Description When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        } else if ( ! isset($prev[$parent][$relationAlias])) {
        {code}

        ...which will always evaluate to true (and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Table.php#L1845]
        When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        } else if ( ! isset($prev[$parent][$relationAlias])) {
        {code}

        ...which will always evaluate to true (and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L155]
        Hide
        Ben Davies added a comment -

        Correct Test Case

        Show
        Ben Davies added a comment - Correct Test Case
        Ben Davies made changes -
        Attachment DC857TestCase.php [ 10771 ]
        Ben Davies made changes -
        Comment [ Ignore number 2 attachment. Number 1 is the right one.
        http://www.doctrine-project.org/jira/secure/attachment/10771/DC857TestCase.php ]
        Hide
        Ben Davies added a comment -

        Correct Test Case

        Show
        Ben Davies added a comment - Correct Test Case
        Ben Davies made changes -
        Attachment DC857TestCase_Correct.php [ 10772 ]
        Ben Davies made changes -
        Attachment DC857TestCase.php [ 10771 ]
        Ben Davies made changes -
        Attachment DC857TestCase.php [ 10770 ]
        Ben Davies made changes -
        Attachment DC857TestCase_Correct.php [ 10772 ]
        Ben Davies made changes -
        Attachment DC857TestCase.php [ 10773 ]
        Ben Davies made changes -
        Description When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        } else if ( ! isset($prev[$parent][$relationAlias])) {
        {code}

        ...which will always evaluate to true (and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L155]
        When objects are hydrated with a join to a one to one relation, if the queried object is stored in the table's cache, and ATTR_HYDRATE_OVERWRITE set to false, then the one to one relation's postHydrate method will never be called.

        This is due to [this line|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L255].

        {code}
        } else if ( ! isset($prev[$parent][$relationAlias])) {
        {code}

        ...which will always evaluate to false, and postHydrate will ever be called, as the record has been pulled from the table cache [here|http://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Hydrator/Graph.php#L155]
        Hide
        Ben Davies added a comment -

        I was probably a little too tired to think this through clearly on a Friday after a long weeks work!
        Patched attached, which doesn't break any of the existing unit tests.

        Show
        Ben Davies added a comment - I was probably a little too tired to think this through clearly on a Friday after a long weeks work! Patched attached, which doesn't break any of the existing unit tests.
        Ben Davies made changes -
        Attachment DC857.patch [ 10774 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DC-857, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Ben Davies
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: