Ticket #740 (closed defect: fixed)

Opened 18 months ago

Last modified 18 months ago

Issue with Doctrine_Record->hydrate() and Doctrine_Record->clean_data()

Reported by: dbrewer Owned by: jackbravo
Priority: critical Milestone: 2.0.0 (OLD)
Component: Query/Hydration Version: 0.9.0
Severity: Keywords:
Cc: jackbravo Has Test:
Status: Has Patch:

Description

After a recent update to the latest revision of 0.9, many of my unit tests started failing with this exception:

Doctrine_Record_Exception: Unknown record property / related component 'collection_id'. in /var/project/www/iqsc/plugins/sfDoctrinePlugin/lib/doctrine/Doctrine/Record/Filter/Standard.php on line 55

This happens under certain circumstances when I am saving a record with foreign key relations which have not been loaded. Through trial and error I narrowed down the exact revision where the problem was introduced. It's r3515 for 0.9, and a similar change was made in r3289 for trunk. This change does seem to fix issues which are discussed in #576 and #583, but it has introduced this new issue.

Interestingly, the patch proposed in #576 seems to fix both #576 and #583 while not introducing the issue that I am encountering. I am looking into this issue and I'll try to make a test case that exposes my issue.

Change History

Changed 18 months ago by romanb

  • priority changed from major to critical

Changed 18 months ago by romanb

  • version set to 0.9

Changed 18 months ago by romanb

  • milestone beta3 deleted

Changed 18 months ago by dbrewer

  • status changed from new to assigned

I have been unable to replicate this with a test case, and I was able to make the issue go away via a change in my code. The issue is related to the fact that I was overloading the save() method in one of my records in order to perform some tasks every time the record was saved. To make matters more complicated there was a record inheritance hierarchy at play here.

The action that I took in the save() method was to call a different class, which then tried to look up the values of some fields in a different record object owned by the record object that I was saving. This second record object was failing to hydrate. When I moved this activity into a postSave() method, the issue went away without any change to Doctrine internals, presumably because the entire save process was allowed to complete properly.

However, getting past this stage has revealed another issue caused by the same revision which I am investigating and will post more details on here shortly.

Changed 18 months ago by jackbravo

Hi dbrewer. I'm very sorry for any inconvenience my PATCH may have caused you. I was just about to ask you for a test case. Anyway keep us informed and I'll help as much I can.

Changed 18 months ago by jackbravo

  • cc jackbravo added

Changed 18 months ago by dbrewer

  • owner changed from dbrewer to jackbravo
  • status changed from assigned to new

A more accurate description of the problem goes something like this: previously, if you loaded a record from the database, then something changed that record in the database, and you loaded the same record again in the same script, any values that had been changed to null in the database would not be updated in the reloaded object. This is because the cleanData method of Doctrine_Record would skip any fields which were both set to null in the input to cleanData and also had a non-null value in the previously loaded version of the record.

I believe this is fixed in r3550 of 0.9 (thanks to jackbravo for all the help on this). I also merged the change into 0.10 (r3552) and trunk (r3551). What I haven't yet been able to do is create a good test case for reproducing the problem so that it doesn't emerge again. However, jackbravo said that he thought he had an idea of how he would approach this, so I'm reassigning this ticket to him to create the test case and then close the ticket.

Changed 18 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.