Warning: Undefined index: target_bundles on Drupal\cer\Entity\CorrespondingReference->synchronizeCorrespondingField()

Created on 16 December 2021, almost 3 years ago
Updated 19 June 2024, 5 months ago

Problem/Motivation

I have two content types, one with LIMITED 1 field and another UNLIMITED.

I setup CER to have both fields corresponding.

When I save content on the content type that has the UNLIMITED, I get the following Notice, but the content is saved correctly.

Steps to reproduce

Using two content type with corresponding fields with LIMITED-UNLIMITED values, and then save a node using the UNLIMITED field.

Notice Log:

Notice: Undefined index: target_bundles na Drupal\cer\Entity\CorrespondingReference->synchronizeCorrespondingField() (linha 350 de /var/www/.../web/modules/contrib/cer/src/Entity/CorrespondingReference.php)

#0 /var/www/.../web/core/includes/bootstrap.inc(346): _drupal_error_handler_real()
#1 /var/www/.../web/modules/contrib/cer/src/Entity/CorrespondingReference.php(350): _drupal_error_handler()
#2 /var/www/.../web/modules/contrib/cer/src/Entity/CorrespondingReference.php(285): Drupal\cer\Entity\CorrespondingReference->synchronizeCorrespondingField()
#3 /var/www/.../web/modules/contrib/cer/cer.module(54): Drupal\cer\Entity\CorrespondingReference->synchronizeCorrespondingFields()
#4 /var/www/.../web/modules/contrib/cer/cer.module(22): cer_sync_corresponding_references()
#5 [internal function]: cer_entity_update()
#6 /var/www/.../web/core/lib/Drupal/Core/Extension/ModuleHandler.php(403): call_user_func_array()
#7 /var/www/.../web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(251): Drupal\Core\Extension\ModuleHandler->invokeAll()
#8 /var/www/.../web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(893): Drupal\Core\Entity\EntityStorageBase->invokeHook()
#9 /var/www/.../web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(602): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()
#10 /var/www/.../web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(778): Drupal\Core\Entity\EntityStorageBase->doPostSave()
#11 /var/www/.../web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(527): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave()
#12 /var/www/.../web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(802): Drupal\Core\Entity\EntityStorageBase->save()
#13 /var/www/.../web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
#14 /var/www/.../web/core/modules/node/src/NodeForm.php(270): Drupal\Core\Entity\EntityBase->save()
#15 [internal function]: Drupal\node\NodeForm->save()
#16 /var/www/.../web/core/lib/Drupal/Core/Form/FormSubmitter.php(114): call_user_func_array()
#17 /var/www/.../web/core/lib/Drupal/Core/Form/FormSubmitter.php(52): Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()
#18 /var/www/.../web/core/lib/Drupal/Core/Form/FormBuilder.php(592): Drupal\Core\Form\FormSubmitter->doSubmitForm()
#19 /var/www/.../web/core/lib/Drupal/Core/Form/FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm()
#20 /var/www/.../web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#21 /var/www/.../web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
#22 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#23 /var/www/.../web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#24 /var/www/.../web/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#25 /var/www/.../web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#26 /var/www/.../web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#27 /var/www/.../vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#28 /var/www/.../vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#29 /var/www/.../web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#30 /var/www/.../web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#31 /var/www/.../web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#32 /var/www/.../web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#33 /var/www/.../web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#34 /var/www/.../web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#35 /var/www/.../web/modules/contrib/remove_http_headers/src/StackMiddleware/RemoveHttpHeadersMiddleware.php(49): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#36 /var/www/.../vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle()
#37 /var/www/.../web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle()
#38 /var/www/.../web/index.php(19): Drupal\Core\DrupalKernel->handle()
#39 {main}

Edit: I have this patched installed:
"drupal/cer": {
"Update existing references on save": " https://www.drupal.org/files/issues/2021-10-03/cer-ignore-original-entit... β†’ "
},

πŸ› Bug report
Status

Needs work

Version

5.0

Component

Code

Created by

πŸ‡΅πŸ‡ΉPortugal jrochate

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

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