Doctrine 1
  1. Doctrine 1
  2. DC-83

Doctrine_Record::fromArray() calls protected methods with wrong arguments when dealing with relations.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Blocker Blocker
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      php 5.3 / symfony 1.3

      Description

      Hi there.

      This a bug related with Symfony but I think the problem comes from Doctrine so I post it here.
      When trying to update an object with this array:

      {{
      var_dump($values)
      array
      'id' => string '14' (length=2)
      'foo' => null
      'bar_relation' =>
      array
      'id' => string '15' (length=2)
      'title' => string '' (length=0)
      'bar_other_relation' =>
      array
      'id' => string '16' (length=2)
      'title' => string '' (length=0)
      }}

      When calling
      {{
      $object->fromArray($values):
      }}

      I'l have this error message:
      {{
      Call to a member function getTable() on a non-object in [...]/Doctrine/Record.php on line 1511.
      }}
      And the stack trace
      {{
      sfFormDoctrine->doSave( ) ../sfFormDoctrine.class.php:218
      sfFormDoctrine->updateObject( ) ../sfFormDoctrine.class.php:415
      sfFormDoctrine->doUpdateObject( ) ../sfFormDoctrine.class.php:249
      Doctrine_Record->fromArray( ) ../sfFormDoctrine.class.php:267
      MyModel->setBarRelation( ) ../Record.php:1923
      sfDoctrineRecord->__call( ) ../sfDoctrineRecord.class.php:0
      call_user_func_array ( ) ../sfDoctrineRecord.class.php:204
      Doctrine_Record->set( ) ../sfDoctrineRecord.class.php:0
      Doctrine_Record->_set( ) ../Record.php:1382
      Doctrine_Record->coreSetRelated( ) ../Record.php:1426
      }}

      Doctrine_Record->coreSetRelated is called with an array instead of a proper Doctrine_Record, and Doctrine try to call ->getTable on this array, causing the error.

      Is this a symfony problem or a doctrine one?

        Activity

        Hide
        Jonathan H. Wage added a comment -

        When I try and reproduce this in a test case with your example it doesn't behave that way. Can you try and make a failing test case for us to look at?

        Show
        Jonathan H. Wage added a comment - When I try and reproduce this in a test case with your example it doesn't behave that way. Can you try and make a failing test case for us to look at?
        Hide
        Marc Weistroff added a comment -

        Thx for the prompt reply Jon. i'll do it asap

        Show
        Marc Weistroff added a comment - Thx for the prompt reply Jon. i'll do it asap
        Hide
        Marc Weistroff added a comment -

        I can't reproduce the case and I found a workaround by changing the name of my embed forms in symfony.

        Show
        Marc Weistroff added a comment - I can't reproduce the case and I found a workaround by changing the name of my embed forms in symfony.
        Hide
        Marc Weistroff added a comment -

        I attach the test case I tried to work on even if it DOES NOT reproduce the problem.

        Show
        Marc Weistroff added a comment - I attach the test case I tried to work on even if it DOES NOT reproduce the problem.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: