Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-232

toArray of PersistentCollection returns an empty collection

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-ALPHA4
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      I've found little error in the class Doctrine\ORM\PersistentCollection in method toArray. There is lost calling of _initialize method probably. This leads to abnormal behavior:

      class Role
      {
      ...
      /**

      • @ManyToMany(targetEntity="Resource")
      • @JoinTable(name="access",
      • joinColumns= {@JoinColumn(name="role_id", referencedColumnName="role_id")}

        ,

      • inverseJoinColumns= {@JoinColumn(name="resource_id", referencedColumnName="resource_id")}
      • )
        */
        private $resources;
        public function makeTest()
        {
        echo count($this->resources->toArray()) . "\n";
        echo count($this->resources) . "\n";
        }
        ...
        }

      Output:
      0
      1

        Issue Links

          Activity

          Hide
          Roman S. Borschel added a comment -

          Should be fixed now.

          Show
          Roman S. Borschel added a comment - Should be fixed now.
          Hide
          Valery Dubrava added a comment -

          Thanks

          Show
          Valery Dubrava added a comment - Thanks

            People

            • Assignee:
              Roman S. Borschel
              Reporter:
              Valery Dubrava
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: