Skip to content

Loading…

DDC-238: PersistentCollection is not initialized when toArray() is called #3089

Closed
doctrinebot opened this Issue · 4 comments

1 participant

@doctrinebot

Jira issue originally created by user nicokaiser:

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();
    }
@doctrinebot

Comment created by romanb:

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

@doctrinebot

Comment created by romanb:

Should be fixed now.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.0-ALPHA4 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.