Improve EntityReferenceRevisionsItem::generateSampleValue to be recursion-safe and devel_generate compatible

Created on 14 September 2015, about 10 years ago
Updated 16 January 2023, over 2 years ago

Following fatal error occurs, when try to generate content via devel_generate when having a paragraphs field included in content type. Maybe this is more a paragraphs related problem or not.

The website encountered an unexpected error. Please try again later.

InvalidArgumentException: Value is not a valid entity. in Drupal\entity_reference_revisions\Plugin\DataType\EntityReferenceRevisions->setValue() (line 118 of modules/contrib/entity_reference_revisions/src/Plugin/DataType/EntityReferenceRevisions.php).
Drupal\Core\Field\FieldItemBase->writePropertyValue('entity', Array)
Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem->onChange('target_id', )
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->setValue(Array, )
Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem->setValue(Array, )
Drupal\Core\TypedData\TypedDataManager->getPropertyInstance(Object, 0, Array)
Drupal\Core\Field\FieldTypePluginManager->createFieldItem(Object, 0, Array)
Drupal\Core\Field\FieldItemList->createItem(0, Array)
Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue(Array, 1)
Drupal\Core\Field\FieldItemList->setValue(Array)
Drupal\Core\Field\FieldItemList->generateSampleItems(3)
Drupal\devel_generate\DevelGenerateBase::populateFields(Object)
Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate->develGenerateContentAddNode(Array)
Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate->generateContent(Array)
Drupal\devel_generate\Plugin\DevelGenerate\ContentDevelGenerate->generateElements(Array)
Drupal\devel_generate\DevelGenerateBase->generate(Array)
Drupal\devel_generate\Form\DevelGenerateForm->submitForm(Array, Object)
call_user_func_array(Array, Array)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object)
Drupal\Core\Form\FormBuilder->processForm('devel_generate_form_content', Array, Object)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\devel\StackMiddleware\DevelMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany IT-Cru Munich

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • First commit to issue fork.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 2 years ago
    Patch Failed to Apply
  • Status changed to Needs work over 1 year ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    It's unclear to me if this is required or not, but I agree that bulk-generation recursive paragraphs on layout builder preview is a problem. The patch also uses an invalid path, so lets at least improve that so tests can run, or better do a merge reuest.

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States capysara

    Applied changes in #51 to the MR and hid all the previous patches.

  • Merge request !482568187 - limit recursion depth to 5. β†’ (Open) created by capysara
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    40 pass
  • Pipeline finished with Failed
    over 1 year ago
    Total: 182s
    #131803
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    40 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    40 pass
  • πŸ‡«πŸ‡·France mattlc

    I'm currently experiencing recursion issue with layout builder (building content type full view display).
    I have a commerce_product with a layout paragraphs field.
    When first attempt to show the layout builder, I enter an infinite loop.

    I applied the same recursion_tracker strategy as the core entity reference field type one.
    Seems to be much better, no more infinite loop.
    So @anybody, totally subscribe to #46.

    Also tested MR and this solves the issue in LB.

    @twod, is there a reason in #51 to have a limit to 5 instead of Entity Reference recursion_tracker strategy ?

Production build 0.71.5 2024