Sonata: Fatal error: Maximum function nesting level of '100'

Discuss Symfony 2 bundles here

Moderators: dcobalt, tiagojsag

Sonata: Fatal error: Maximum function nesting level of '100'

Postby sibok » Wed Jun 20, 2012 3:27 pm

Hi,

i've created 3 Admins for 3 entities linked to each other, where A Admin is embedding B Admin and B Admin embeds C Admin. B entity has a ManyToOne relation with A and B entity.

A entity embeds B entity with the following code:
Code: Select all
                    $formMapper->add('b', 'sonata_type_collection', array(
                                'by_reference' => false
                            ), array(
                                'edit' => 'inline',
                                'inline' => 'table',
                                'sortable'  => 'position'
                            ) );


B entity embeds C entity with the following one:
Code: Select all
 $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' in favour of 'edit' => 'standard' avoids the following error


Placing array( 'edit' => 'list' ) on B Admin entity on a sonata_type_model form type gives the following error while editing A enity. If instead array( 'edit' => 'standard' ) is used 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
The tricky or curious thing is that no matter if edit is list or standard if i go to B admin to edit it. the problem only appears if i edit B embedded into A with edit list option set. And this is happening to me in some other entities where i implemented the same behaviour.

Here are A, B and C entity and how they link each other:

A entity:
Code: Select all
    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; 
    } 


B entity:
Code: Select all
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;
    } 

C entity:
Code: Select all
    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 it all you can use sonata demo project to check for a similar behaviour.
As you can see it is the same use case which can be found on Sonata Project demo where Gallery is linked against GalleHasMedias which links against Media: http://demo.sonata-project.org/admin/so ... xt=default As you can see, GalleryHasMedia has a ManyToOne relation with Gallery and another one with Media so when you edit a Gallery ou can see a sonata_type_model with edit' => 'inline','inline' => 'table', so a GalleryHasMedia is embedded inside Gallery form in order to be able to add new Medias which are going to be linked with the current Gallery and stored inside GalleryHasMedia.

Has any one faced a situation like the exposed one? Hope someone could point to the right direction or help to get a clue on what's going on.

PD: For me it seems like B and C entities are linking/embedding each other in an endless loop. But as said, 3 Admins are working great separately (while A does not embeds B).
sibok
Junior Member
 
Posts: 8
Joined: Mon Jun 04, 2012 11:25 am

Return to Bundles discussion

Who is online

Users browsing this forum: No registered users and 1 guest