Doctrine 1
  1. Doctrine 1
  2. DC-810

Doctrine relations: Doctrine_Record::fromArray() does not update local field when new linked record is created

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:

      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.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Paolo Agostinetto
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: