Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-833

Internal Collection of a PersistentCollection is an Entity

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-RC1
    • Fix Version/s: 2.0-RC1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      # Windows Vista
      # Apache 2.2.14
      # MySQL 5.1.41
      # PHP 5.3.1
      # Perl 5.10.1
      # PHPUnit 3.5.0

      Description

      The creation of an Associated Collection of a Proxy Class is broken by this line:

      $reflField->getValue($entity) ?: new ArrayCollection
      

      $entity is a Proxy Class and the property is the field users. The function ReflectionProperty::getValue() will return an Entity User. This results that the internal collection of the PersistenCollection is an Entity. This results in:

      Fatal error: Call to undefined method Entity\User::clear() in \library\Doctrine\ORM\PersistentCollection.php on line 206
      

      This is my Entity Configuration

      class Organization {
          /**
           * @OneToMany(targetEntity="User", mappedBy="organization", cascade={"persist", "remove"})
           */
          private $users;    
      
          public function __constructor() {
            $this->users = new ArrayCollection();
         }
      }
      
      class User {
          /**
           * @ManyToOne(targetEntity="Organization", inversedBy="users")
           * @JoinColumn(name="organization_id", referencedColumnName="id")
           */	
       	private $organization; 	
      }
      

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Fixed formatting

        Show
        Benjamin Eberlei added a comment - Fixed formatting
        Hide
        Benjamin Eberlei added a comment -

        I don't understand why this $reflField->getValue() returns a user entity. It should only return either NULL or a collection.

        Show
        Benjamin Eberlei added a comment - I don't understand why this $reflField->getValue() returns a user entity. It should only return either NULL or a collection.
        Hide
        Benjamin Eberlei added a comment -

        fixed aswell as another nasty bug.

        Show
        Benjamin Eberlei added a comment - fixed aswell as another nasty bug.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Jeff Reiffers
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: