Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Maximum function nesting level of '250' reached, aborting! #281

Closed
simplenotezy opened this issue Nov 16, 2015 · 10 comments
Closed

Maximum function nesting level of '250' reached, aborting! #281

simplenotezy opened this issue Nov 16, 2015 · 10 comments

Comments

@simplenotezy
Copy link

Having run 3.0.0 successfully, after recently updating using composer update I get the following error, when I do:

$model = My\Models\Model::find(1);

Returns:

Maximum function nesting level of '250' reached, aborting!

This worked before running composer update.

@simplenotezy
Copy link
Author

Funny thing is, if I instead do:

$model = My\Models\Model::whereId(1)->first();

or

$model = My\Models\Model::findOrFail(1);

It works

@simplenotezy
Copy link
Author

I have tried switching back to the initial 3.0.0 release, but the error is the same. Guess I haven't used ::find() for a while.

@igorsantos07
Copy link
Member

Guess I haven't used find in a while as well, @canfiax. Just so you know: activating throwOnFind prevents the loop, that's why I never saw it until now :)
It seems the issue is explained on #283. See if it's fixed for you in 3.1.1!

@rmarliere
Copy link

I'm also having this error, but for the version 2.5.0. I had to rollback to version 2.4.2.

@ManiacTwister
Copy link

@igorsantos07
I have this problem too. I'm using version 3.3.0 and laravel 5.2 (Is it even supposed to work with 5.2?)

When i call find() (or all() and probably any other database action) i get memory exhaused because of a infinite loop:

LaravelArdent\\Ardent\\Ardent::find() /var/www/app/Http/Controllers/BlogController.php:27, 
LaravelArdent\\Ardent\\Ardent->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:914, 
Illuminate\\Database\\Eloquent\\Model->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:387, 
LaravelArdent\\Ardent\\Ardent->newQuery() /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3546, 
LaravelArdent\\Ardent\\Ardent->applyGlobalScopes() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934, 
LaravelArdent\\Ardent\\Ardent->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934, 
Illuminate\\Database\\Eloquent\\Model->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:387, 
LaravelArdent\\Ardent\\Ardent->newQuery() /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3546, 
LaravelArdent\\Ardent\\Ardent->applyGlobalScopes() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934, 
LaravelArdent\\Ardent\\Ardent->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934, 
[...]

@igorsantos07
Copy link
Member

@ManiacTwister, would you provide us with a gist of the affected model, the
table structure, and the exact call you're making? I do use all() and
find() but do not face those issues.

Igor Santos
-- Desenvolvedor Web
[enviado do meu celular]
On 15 Jan 2016 15:00, "ManiacTwister" [email protected] wrote:

@igorsantos07 https://github.com/igorsantos07
I have this problem too. I'm using version 3.3.0 and laravel 5.2 (Is it
even supposed to work with 5.2?)

When i call find() (or all() and probably any other database action) i get
memory exhaused because of a infinite loop:

LaravelArdent\Ardent\Ardent::find() /var/www/app/Http/Controllers/BlogController.php:27,
LaravelArdent\Ardent\Ardent->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:914,
Illuminate\Database\Eloquent\Model->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:387,
LaravelArdent\Ardent\Ardent->newQuery() /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3546,
LaravelArdent\Ardent\Ardent->applyGlobalScopes() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934,
LaravelArdent\Ardent\Ardent->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934,
Illuminate\Database\Eloquent\Model->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:387,
LaravelArdent\Ardent\Ardent->newQuery() /var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3546,
LaravelArdent\Ardent\Ardent->applyGlobalScopes() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934,
LaravelArdent\Ardent\Ardent->__call() /var/www/vendor/laravelbook/ardent/src/Ardent/Ardent.php:934,
[...]


Reply to this email directly or view it on GitHub
#281 (comment)
.

@ManiacTwister
Copy link

@michaelfarrow
Copy link

I just ran into this issue myself. Looks like laravel/framework@ca15fe7 removed applyGlobalScopes() and moved it's logic to newQuery() causing _call() on the Ardent and Eloquent models to loop.

@ilyashtrikul
Copy link

+1 Same problem. Please fix it.
But i had infinite loop with $model->load('relation_name') method.
Infinite loop in LaravelArdent\Ardent\Ardent class

public function newQuery($excludeDeleted = true) {
    ...
    return $this->applyGlobalScopes($builder); // loop in this calling
}

@igorsantos07
Copy link
Member

@weyforth got it right, the issue is in the snippet by @shtricul. This is a pretty small fix, related to changed in Laravel between 4 and 5. The weirdest thing is it only happens sometimes, when it should happen every time we do any kind of find, I think.

The fix will be published soon on 3.4.2, as this is a bugfix for an internal API. However, PLEASE use caution when updating, I'm not entire sure it would not bring any troubles with it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants