After upgrading symfony from 1.2 to 1.4, my website began to have problems saving some models. After some research, I found that it was caused by infinite recursion. Let's say Model A has many B (B belongs to A). Each A also points to one of the B objects it owns. So it's a circular reference. Some ppl might argue that it's not a good pratice to have circular reference in the data model, I agree. But it worked fine in Doctrine 1.0, so I prefer not to change it. In Doctrine 1.2.1, it seems that when A and its related B are both modified (dirty), if I try to save A, Doctrine will try to save B due to cascade update, and when saving B, it will again try to save its related A ...
I compared the source code of Doctrine_Connection_UnitOfWork between 1.0 and 1.2.1, and found out that in Doctrine 1.2.1, the model is no longer locked when saveRelatedLocalKeys is invoked. I don't understand this change. After I changed the line "$this->saveRelatedLocalKeys($record);" to
$record->state($record->exists() ? Doctrine_Record::STATE_LOCKED : Doctrine_Record::STATE_TLOCKED);
my website returned to normal again. And so far i haven't found any problem caused by my change
So I hope someone can look into this and let me know if my change is safe. Or if I'm wrong, is there any way I can get around the infinite recursion problem without changing my database schema? Thanks.