Sonata: Fatal error: the maximum nesting level of the function "100" is reached .. when embedding forms

EDIT: for anyone interested in solving the same problem, this did the trick:

echo `'xdebug.max_nesting_level = 250' >> /etc/php5/conf.d/xdebug.ini` 

I created 3 Admins for 3 entities related to each other, where Admin embeds B Admin and B Admin implements C Admin. B has ManyToOne related to objects A and B.

The object enters object B with the following code:

 $formMapper->add('b', 'sonata_type_collection', array( 'by_reference' => false ), array( 'edit' => 'inline', 'inline' => 'table', 'sortable' => 'position' ) ); 
An object

B inserts an object C with the following:

  $formMapper->add( 'c', 'sonata_type_model', array( 'required' => true, 'label' => ucfirst( $this->trans( 'c', array(), $this->translationDomain, $this->langCode ) ) ), array( 'edit' => 'list' ) ); 

Note: changing 'edit' => 'list' to 'edit' => 'standard' avoids the following error.

Placing array( 'edit' => 'list' ) of the BB object in the form of the sonata_type_model form gives the following error while editing A enity. If array( 'edit' => 'standard' ) used instead, then no error is output:

 Sonata: Fatal error: Maximum function nesting level of '100' reached, aborting! in myProject/vendor/doctrine-common/lib/Doctrine/Common/Lexer.php on line 756 

It is difficult or curious that regardless of whether editing is a list or standard, if I go to administrator B to edit it. the problem only occurs if I edit B built in with the edit list option set. And this happens to me in some other objects, where I implemented the same behavior.

Here is the essence of A, B, and C and how they relate to each other:

Essence:

 class A { /** * @ORM\Id * @ORM\Column(type="integer", length=4) * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** @ORM\OneToMany(targetEntity="B", mappedBy="a", cascade={"persist"}, orphanRemoval=true ) */ protected $b; } 

Object B:

 class B { /** * @ORM\Id * @ORM\Column(type="integer", length=4) * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id /** * @ORM\ManyToOne(targetEntity="C", inversedBy="b", cascade={"persist"} ) * @ORM\JoinColumn(name="c_id", nullable=false, referencedColumnName="id", onDelete="CASCADE") */ private $c; /** * @ORM\ManyToOne(targetEntity="A", inversedBy="b", cascade={"persist"} ) * @ORM\JoinColumn(name="a_id", nullable=false, referencedColumnName="id", onDelete="CASCADE") */ private $a; } 

Object C:

 Class C { /** * @ORM\Id * @ORM\Column(type="integer", length=4) * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; /** @ORM\OneToMany(targetEntity="B", mappedBy="c", cascade={"persist"} ) */ private $b; } 

To be able to take a look at all this, you can use the sonata demo project to test similar behavior.
As you can see, this is the same use case that can be found in the Sonata Project demo, where Gallery is linked to GalleHasMedias, which links to Media: http://demo.sonata-project.org/admin/sonata/media/gallery/ 255 / edit? Context = default As you can see, GalleryHasMedia has ManyToOne related to Gallery and the other to Media, so when you edit Gallery you can see sonata_type_model with edit' => 'inline','inline' => 'table', therefore GalleryHasMedia is built into the Gallery form to be able to add new Medias that will be associated with the current gallery and saved inside GalleryHasMedia .

Has anyone encountered a situation like this exposed? Hopefully someone can point in the right direction or help understand what is happening.

PD: for me it seems that objects B and C connect / embed each other in an infinite loop. But as said, 3 admins work fine (while A does not insert B).

+7
source share
2 answers

For anyone interested in solving the same problem, this did the trick:

 echo `'xdebug.max_nesting_level = 250' >> /etc/php5/conf.d/xdebug.ini` 
0
source

This is a common problem with servers running xdebug. You should increase the nesting level by increasing xdebug.max_nesting_level in the xdebug.ini configuration. Installing it on something like 250 should be sufficient.

One quick way to add this parameter is to do this on the linux server:

 echo `'xdebug.max_nesting_level = 250' >> /etc/php5/conf.d/xdebug.ini` 
+5
source

All Articles