Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-238

PersistentCollection is not initialized when toArray() is called

    Details

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

      Description

      When receiving entities from the database, collections are received as PersistentCollection objects.

      A PersistentCollectionmay not be initialized (i.e. its elements are not loaded), this is done via "_initialize()" when the elements are accessed for the first time (i.e. forAll() or the corresponding "foreach" call).

      However when toArray() is called, the _initialize() call is missing, so the method may return an empty array even if the collection has elements.

      Shouldn't PersistentCollection::toArray() look like this?

          public function toArray()
          {
              $this->_initialize();
              return $this->_coll->toArray();
          }
      

        Issue Links

          Activity

          Hide
          Roman S. Borschel added a comment -

          Right, we got this reported two times already (this is the third) so I guess I better go fix this now

          Show
          Roman S. Borschel added a comment - Right, we got this reported two times already (this is the third) so I guess I better go fix this now
          Hide
          Roman S. Borschel added a comment -

          Should be fixed now.

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: