samedi 26 septembre 2015

Issue with middleware "Maximum function nesting level of '100' reached, aborting!"

I had a controller, lets call it DummyController, that performs CRUD operations in the root of controllers folder. I have moved dummy controller into a different directory, a level higher, so our DummyController is now in folder named 'r'.

Due to that I have updated the edit form, which is used with dummy controller:

{!! Form::model($message, ['method' => 'PATCH', 'action' => ['r\DummyController@update', $message->id]]) !!} 

And now it's broken. I have tried playing around with controller and narrowed the issue down to middleware that I use in Dummy Controller. I have 'auth' middleware and my own 'role' middleware:

if (Auth::user()->role_id != config('Roles.admin')) {
            return redirect('/');
        }

If I remove one middleware everything starts working, I cant have both running, which is strange because before it worked fine.



via Chebli Mohamed

2 commentaires:

Unknown a dit…
Ce commentaire a été supprimé par l'auteur.
Unknown a dit…

That issue is caused by a setting in your xdebug nesting levels. Usually the nesting level are set to 100. But sometimes the nesting in the controller can go above 100.
I found a fix by increasing my maximum nesting level to above 100 by doubling it to 200.

Add this line
"ini_set('xdebug.max_nesting_level', 120);"
(Without the quotes) to your
"bootstrap/autoload.php" file.
This resets the max nesting level to 200 and the error will go away.

Enregistrer un commentaire