spicywebau / craft-neo

A Matrix-like field type for Craft CMS that uses existing fields
Other
402 stars 63 forks source link

Craft 2 Neo: Fatal error: Nesting level too deep - recursive dependency? #473

Closed brianrivet-tilt closed 3 years ago

brianrivet-tilt commented 3 years ago

Description

I'm having a problem getting a Craft 2 site I'm trying to upgrade to Craft 3 running in my local dev environment. The site is running Neo and it is showing me the following error on all of my pages:

Fatal error: Nesting level too deep - recursive dependency? in /home/vagrant/sites/lpb-c3/craft/plugins/neo/models/Neo_CriteriaModel.php on line 226

The site runs on the production server with no issues. The production server is a Laravel Forge setup on Linode. I'm guessing there is something configured differently in my local environment that is causing Neo to fail but I'm not sure what it is. Can you assist me?

Other information

ttempleton commented 3 years ago

Hmm, I haven't had that error occur locally and I'm not sure what would cause it in terms of configuration, sorry. But I think it should work if you change that line of craft/plugins/neo/models/Neo_CriteriaModel.php from

return $a === $b ? 0 : ($a > $b ? 1 : -1);

to

return $a->lft === $b->lft ? 0 : ($a->lft > $b->lft ? 1 : -1);

If you make that change, does everything work as expected including correct ordering of the Neo blocks?

timeverts commented 3 years ago

We spent a long time last year looking into this issue without finding any bullet proof way to resolve it. We discovered this issue only occurs on PHP 7.3 or higher, as we were attempting to upgrade several existing Craft 2 sites from PHP 7.2 to 7.4. To this day they're still running on PHP 7.2 because of this exact issue.

I'm going from memory now, but I believe it was something to do with the storage of the block models in the criteria and properties like descendants, children, siblings etc, would self reference the same block model over and over.

I haven't tried the fix above though, so will take a look in the next couple of days.

brianrivet-tilt commented 3 years ago

I plan to give it a try today. I'll post to let you know how it goes.

timeverts commented 3 years ago

@brianrivet-tilt, did you try this fix out?

brianrivet-tilt commented 3 years ago

sorry, yes I did and the fix worked just fine!