DDC-204: ActiveEntity persistent object recursion on self referencing class #254

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

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

Originally assigned to: @jwage on GitHub.

Jira issue originally created by user russ:

When using a self-referencing relationship, for example:

  /****
   * @ManyToOne(targetEntity="Collection")
   * @JoinColumn(name="parent_id", referencedColumnName="id")
   * 
   * @var Collection
   */
  protected $parent;

ActiveEntity::toArray() recurses through all parents and children.

This was all working fine until my database actually started getting some data... then XDebug stopped me with a "Maximum function nesting level of '100' reached, aborting!" error.

..
..
95 0.2574 14222056 Proxies\CollectionProxy->toArray( ) ..\ActiveEntity.php:164 
96 0.2574 14222056 DoctrineExtensions\ActiveEntity->toArray( ) ..\CollectionProxy.php:183 
97 0.2576 14231520 Proxies\CollectionProxy->toArray( ) ..\ActiveEntity.php:173 
98 0.2576 14231520 DoctrineExtensions\ActiveEntity->toArray( ) ..\CollectionProxy.php:183 
99 0.2576 14231736 Doctrine\ORM\EntityManager->getClassMetadata( ) ..\ActiveEntity.php:150 

The PersistentCollection object does not have a state so cannot be locked in the same was as an ActiveEntity object can - maybe it needs a lockable state for this to work?

Originally created by @doctrinebot on GitHub (Dec 10, 2009). Originally assigned to: @jwage on GitHub. Jira issue originally created by user russ: When using a self-referencing relationship, for example: ``` /**** * @ManyToOne(targetEntity="Collection") * @JoinColumn(name="parent_id", referencedColumnName="id") * * @var Collection */ protected $parent; ``` ActiveEntity::toArray() recurses through all parents and children. This was all working fine until my database actually started getting some data... then XDebug stopped me with a "Maximum function nesting level of '100' reached, aborting!" error. ``` .. .. 95 0.2574 14222056 Proxies\CollectionProxy->toArray( ) ..\ActiveEntity.php:164 96 0.2574 14222056 DoctrineExtensions\ActiveEntity->toArray( ) ..\CollectionProxy.php:183 97 0.2576 14231520 Proxies\CollectionProxy->toArray( ) ..\ActiveEntity.php:173 98 0.2576 14231520 DoctrineExtensions\ActiveEntity->toArray( ) ..\CollectionProxy.php:183 99 0.2576 14231736 Doctrine\ORM\EntityManager->getClassMetadata( ) ..\ActiveEntity.php:150 ``` The PersistentCollection object does not have a state so cannot be locked in the same was as an ActiveEntity object can - maybe it needs a lockable state for this to work?
admin added the Bug label 2026-01-22 12:32:26 +01:00
admin closed this issue 2026-01-22 12:32:26 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 1, 2010):

Comment created by @jwage:

Is this still a problem or has it been fixed?

@doctrinebot commented on GitHub (Mar 1, 2010): Comment created by @jwage: Is this still a problem or has it been fixed?
Author
Owner

@doctrinebot commented on GitHub (Mar 16, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Mar 16, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/e88d4150336cebd71e65

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/e88d4150336cebd71e65 - [10248_ActiveEntity-DDC-204.diff](https://gist.github.com/e88d4150336cebd71e65#file-10248_ActiveEntity-DDC-204-diff)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#254