Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I tried to export a node with paragraphs and an entity reference to a media entity in the paragraphs. There i got the following error:
PHP Fatal error: Nesting level too deep - recursive dependency? in /Users/christianfritsch/repositories/thunder/thunder/profiles/thunder/modules/default_content/src/DefaultContentManager.php on line 345
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/drush:0
PHP 2. require() /usr/local/bin/drush:10
PHP 3. drush_startup() phar:///usr/local/bin/drush/drush:114
PHP 4. drush_main() phar:///usr/local/bin/drush/includes/startup.inc:325
PHP 5. Drush\Boot\BaseBoot->bootstrap_and_dispatch() phar:///usr/local/bin/drush/includes/preflight.inc:66
PHP 6. drush_dispatch() phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php:67
PHP 7. call_user_func_array:{phar:///usr/local/bin/drush/includes/command.inc:185}() phar:///usr/local/bin/drush/includes/command.inc:185
PHP 8. drush_command() phar:///usr/local/bin/drush/includes/command.inc:185
PHP 9. _drush_invoke_hooks() phar:///usr/local/bin/drush/includes/command.inc:217
PHP 10. call_user_func_array:{phar:///usr/local/bin/drush/includes/command.inc:366}() phar:///usr/local/bin/drush/includes/command.inc:366
PHP 11. drush_default_content_export_references() phar:///usr/local/bin/drush/includes/command.inc:366
PHP 12. Drupal\default_content\DefaultContentManager->exportContentWithReferences() /Users/christianfritsch/repositories/thunder/thunder/profiles/thunder/modules/default_content/drush/default_content.drush.inc:85
PHP 13. Drupal\default_content\DefaultContentManager->getEntityReferencesRecursive() /Users/christianfritsch/repositories/thunder/thunder/profiles/thunder/modules/default_content/src/DefaultContentManager.php:266
PHP 14. array_unique() /Users/christianfritsch/repositories/thunder/thunder/profiles/thunder/modules/default_content/src/DefaultContentManager.php:345
Comment | File | Size | Author |
---|---|---|---|
#20 | 2724281-recursion-20.patch | 6.58 KB | andypost |
| |||
#20 | 2724281-recursion-test-only.patch | 1.93 KB | andypost |
#20 | interdiff.txt | 4.6 KB | andypost |
#15 | 2724281-15.patch | 4.83 KB | andypost |
|
Comments
Comment #2
jwilson3I can confirm this error happens when trying to export paragraphs to code.
* Paragraphs-8.x-1.0-rc5
* Default_content-8.x-1.x-dev
The problem is definitely coming from this line in class DefaultContentManager::getEntityReferencesRecursive()
Comment #3
sqndr CreditAttribution: sqndr at Randstad Digital commentedI just stumbled upon the same issue, when exporting a node (
drush dce node 1 --folder=node
) that contains multiple paragraph fields.Comment #4
pguillard CreditAttribution: pguillard commentedI had the same problem, and found out the same solution.
Comment #5
andypostThis is wrong fix
Actual problem here that ContentEntityBase::referencedEntities() does not returns keyed array as the module supposes
Comment #6
andypostPatch fixes the recursion by indexing entities by
type:ID
Also it changes protected method in BC way
PS: formattable changes could be separate but check for interface should be there to prevent php errors about passing other then ContentEntityInterface
Comment #8
andypostProper condition
Comment #10
andypostSomething weird with bot and last patch is wrong
Comment #11
andypostLooks passing by reference better
Comment #12
andypostClosed as duplicate also passing array by reference keeps memory usage low
Comment #14
andypostComment #15
andypostPatch against 8.x-1.x
Comment #16
larowlanAny reason we can't use $entity->uuid() here instead?
Other than that, looks RTBC to me.
Comment #17
gaydabura CreditAttribution: gaydabura as a volunteer and at Skilld commented@andypost, much better then detect max level.
@larowlan actually this hash is temporary and uuid is in returned array as key.
http://cgit.drupalcode.org/default_content/tree/src/DefaultContentManage...
RTBC to me aswell
Comment #18
andypostI think we need tests for nesting
Also uuid vs hash is a good question, the main idea is to keep that key easy to debug
OTOH as @Alexey pointed we already use uuid to index
Comment #19
andypostComment #20
andypostRemoved key gen method and using uuid
Here's a test, before patch only 2 entities are exported
Comment #22
larowlanLooks good to me.
Will leave at RTBC till Monday then commit
Comment #24
larowlanFixed - thanks!