Ticket #786 (closed defect: fixed)

Opened 17 months ago

Last modified 16 months ago

Doctrine_Hydrate_Record::getElement() clearRelated() conflicting with previous queries

Reported by: jwage Owned by: romanb
Priority: minor Milestone: 0.10.3
Component: Other Version: 0.10.0
Severity: Keywords:
Cc: Has Test:
Status: Has Patch:

Description (last modified by jwage) (diff)

In getElement() their is a piece of code which checks for a record in the identify map then clears the related records. This causes issues when you have 2 queries where they hydrate the same data where the first query joins in some additional data, but the 2nd one doesn't. The 2nd query will clearRelated() on the referenced object from the first query, and the things you joined/hydrated in the first query are not present anymore.

Removing the clearRelated() line of code fixes the described issue above, but it also has this affect on the 0.9 tests.

It adds 4 failing tests overall. 7 new fails, but it also fixes 3 tests that fail with clearRelated()

Breaks:
Doctrine_Ticket_428_TestCase : method testAggregateValueMappingSupportsLeftJoins failed on line 43
Doctrine_Ticket_428_TestCase : method testAggregateValueMappingSupportsLeftJoins failed on line 49 count aggregate value should be available
Doctrine_Record_TestCase : method testSaveAssociations failed on line 768
Doctrine_Record_TestCase : method testSaveAssociations failed on line 769
Doctrine_Record_TestCase : method testSaveAssociations failed on line 794
Doctrine_Record_TestCase : method testSaveAssociations failed on line 795
Doctrine_Record_TestCase : method testSaveAssociations failed on line 802

Fixes:
Doctrine_TreeStructure_TestCase : method testTreeLeafRelationships failed on line 111 
Doctrine_Relation_Nest_TestCase : method testNestRelationsFetchingData failed on line 139 
Doctrine_Relation_Nest_TestCase : method testNestRelationsFetchingData failed on line 144 

Change History

Changed 17 months ago by jwage

  • description modified (diff)

Here is the failing test case for the issue:  http://svn.phpdoctrine.org/branches/0.9/tests/Ticket/786TestCase.php

It exists in both 0.9 and 0.10 branch. This should also be rewritten for the new test suite in trunk.

Changed 16 months ago by jwage

  • version changed from 0.9 to 0.10
  • milestone changed from 1.0 to 0.10.3

Changed 16 months ago by romanb

  • status changed from new to closed
  • resolution set to fixed

(In [3930]) Fixed #786.

Changed 16 months ago by romanb

Retaining relations of objects that are already in memory should be expected behavior. If this is unwanted in specific cases it can be solved by manually cutting existing relations (clearRelated()) which will cut all the object's relations in-memory or refresh(true) to re-populate the related elements from the db.

Addressed in [3930].

Note: See TracTickets for help on using tickets.