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

        Hide
        Ben Davies added a comment -

        Test case attached.

        Show
        Ben Davies added a comment - Test case attached.
        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
        Hide
        Ben Davies added a comment -

        Correct Test Case

        Show
        Ben Davies added a comment - Correct Test Case
        Hide
        Ben Davies added a comment -

        Correct Test Case

        Show
        Ben Davies added a comment - Correct Test Case
        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.

          People

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

            Dates

            • Created:
              Updated: