[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 Created: 03/Sep/10  Updated: 05/Sep/10

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: 1.2.3
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Ben Davies Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

All


Attachments: Text File DC857.patch     File DC857TestCase.php    

 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



 Comments   
Comment by Ben Davies [ 03/Sep/10 ]

Test case attached.

Comment by Ben Davies [ 03/Sep/10 ]

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

Comment by Ben Davies [ 03/Sep/10 ]

Correct Test Case

Comment by Ben Davies [ 03/Sep/10 ]

Correct Test Case

Comment by Ben Davies [ 05/Sep/10 ]

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.

Generated at Mon Sep 22 14:23:28 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.