DDC-216: PersistentCollection#toArray() should call _initialize() #270

Closed
opened 2026-01-22 12:32:56 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 17, 2009).

Jira issue originally created by user itoijala:

Calling toArray on a PersistentCollection does not initialize the collection. This means that a not yet initialized collection returns an empty array. This is not expected behavior. The user expects the collection to be initialized and the objects returned. Calling count first is a workaround to initialize the array because count calls _initialize.

A use case is an accessor wanting to return an array to not expose the collection to modification.

Originally created by @doctrinebot on GitHub (Dec 17, 2009). Jira issue originally created by user itoijala: Calling toArray on a PersistentCollection does not initialize the collection. This means that a not yet initialized collection returns an empty array. This is not expected behavior. The user expects the collection to be initialized and the objects returned. Calling count first is a workaround to initialize the array because count calls _initialize. A use case is an accessor wanting to return an array to not expose the collection to modification.
admin added the Bug label 2026-01-22 12:32:56 +01:00
admin closed this issue 2026-01-22 12:32:56 +01:00
Author
Owner
@doctrinebot commented on GitHub (Dec 17, 2009): - is duplicated by [DDC-238: PersistentCollection is not initialized when toArray() is called](http://www.doctrine-project.org/jira/browse/DDC-238) - is duplicated by [DDC-232: toArray of PersistentCollection returns an empty collection](http://www.doctrine-project.org/jira/browse/DDC-232)
Author
Owner

@doctrinebot commented on GitHub (Jan 5, 2010):

Comment created by romanb:

Should be fixed now.

@doctrinebot commented on GitHub (Jan 5, 2010): Comment created by romanb: Should be fixed now.
Author
Owner

@doctrinebot commented on GitHub (Jan 5, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jan 5, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#270