Sub-entity cloning has unnecessary recursion for form causing memory issues

Created on 31 October 2018, about 6 years ago
Updated 10 May 2024, 7 months ago

I'm using the latest dev release and the patch from Issue 2945192 comment #16 🐛 Fatal error: Maximum function nesting level of '256' reached, aborting! With Support for sub-entity cloning patch Fixed and running into a Fatal Error with respect to memory limit.

I have a Node (A) trying to clone into new Node (Z), that has a paragraph field which then has entity fields referencing other Nodes (B, C, D). It's being used as a Related Content feature. When I access the Clone tab on Node A it fails to load. The recursion of the checkbox creation for sub-entity cloning is digging into the values of Nodes B, C, D which have references to other Nodes E, F, G and so on. This keeps going until the page runs out of memory.

At one point it had over 340 fully loaded entities in the "$discovered_entities" on the page, which was the the patch's attempt at limiting the reloading entities, but in my system I had hundreds of nodes linked together in this way that it becomes circular, Node A -> Node C -> Node F -> Node A -> Node C, etc. Although it doesn't reload the entity, it still tries to create a checkbox for it.

I don't think the form building should recurse down into reference entities UNLESS they have been checked on to be cloned themselves. If I want Node (A) and Node (Z) to both reference the same Node (B), then there's no reason to recurse into Node (B) to load all its fields. So that would mean the form would have to use some type of ajax building instead of the full recursing it does today.

I'm going to attempt to look at an ajax solution, or some global setting to limit how many levels deep this goes because it's unusable for certain pieces of content on my site.

If anyone has thoughts or suggestions, please reach out. I'll be hanging out on the Drupal slack channel - @nsciacca.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States nsciacca

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024