Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.2
-
Fix Version/s: None
-
Component/s: Record
-
Labels:None
-
Environment:Hide$uname -a
Linux debianVM 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux
$php -v
PHP 5.2.11-1 with Suhosin-Patch 0.9.7 (cli) (built: Sep 20 2009 12:28:20)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans
with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH
Show$uname -a Linux debianVM 2.6.30-2-686 #1 SMP Sat Sep 26 01:16:22 UTC 2009 i686 GNU/Linux $php -v PHP 5.2.11-1 with Suhosin-Patch 0.9.7 (cli) (built: Sep 20 2009 12:28:20) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH
Description
Doctrine_Record::fromArray() does not update local field when new linked record is created.
Case:
1. I have a model1 with a hasOne relation to model2.
2. I have a record in model1 with no model2 related
3. Then i try to update model1 adding a new related model2 record using Doctrine_Record::fromArray(), model2 is created (Doctrine_Record::toArray() shows me the new row in model2, created and linked to model1)
4. When I save and refresh model1, relation disappear (local field on model1 who links to model2 is empty).
So it seems that Doctrine_Record::fromArray() doesn't recognize the change on model1 if I link it to a new foreign record. In fact if I modify some other field in model1, create and link a new model2 record, all works good!
Digging in Record.php I found a trick, Doctrine_Record::fromArray() doesn't update the state of the model when relations are touched, so I force record state to Doctrine_Record::STATE_DIRTY.
Diff file is attached, but it's still a workaround.