Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.1.4
-
Fix Version/s: None
-
Component/s: Connection
-
Labels:None
-
Environment:Debian 5.0.3, PHP 5.2.11-0.dotdeb.1 with Suhosin-Patch 0.9.7
Description
Hello guys,
at first my ERM:
[Table1] --1---*--> [Table1Sub] --1---1--> [Table2] --1---*--> [Table2Sub]
I want to add datasets in Table1, Table1Sub and Table2Sub. Table2 already has a dataset. So I try
<?php $table1 = new Table1; $table1->fromArray($someDataForTable1); $table1sub = new Table1Sub; $table1sub->fromArray($someDataForTable1Sub); // table2_id is set, so everything is right $table2sub = new Table2Sub; $table2sub->fromArray($someDataForTable2Sub); $table1sub->table2->table2sub[] = $table2sub; $table1->table1sub[] = $table1sub; $table1->save(); ?>
Doctrine saves all datasets but Table2Sub.
I reversed engineer a while, and found in Doctrine_Connection_UnitOfWork::saveRelatedLocalKeys() the if condition isModified().
So, Table2Sub is not saved, because Table2 is not modified. When a changed it to isModified(true), Doctine saves everything.
Is it possible to add the attached patch?
BTW: Can somebody add a 'return $this' in Doctrine_Record::fromArray()?
Greets,
Dominik
It is not this way due to performance reasons. Checking if any related records are dirty would be too slow. If you want to force it to save you can change the state of the object manually.
$obj->state('DIRTY');