Cannot save commerce order type with entity_redirect enabled

Created on 3 March 2022, almost 3 years ago
Updated 6 April 2023, over 1 year ago

Problem

With entity_redirect enabled, I am unable to save a drupal commerce order type.
Works ok without.
Stack:

Error: Cannot create references to/from string offsets in Drupal\Component\Utility\NestedArray::setValue() (line 155 of /app/web/core/lib/Drupal/Component/Utility/NestedArray.php)

#0 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1250): Drupal\Component\Utility\NestedArray::setValue(Array, Array, NULL)
#1 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1001): Drupal\Core\Form\FormBuilder->handleInputElement('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#2 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1071): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#3 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1071): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#4 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1071): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#5 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(1071): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#6 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(575): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#7 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(321): Drupal\Core\Form\FormBuilder->processForm('commerce_order_...', Array, Object(Drupal\Core\Form\FormState))
#8 /app/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\commerce_order\Form\OrderTypeForm), Object(Drupal\Core\Form\FormState))
#9 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#10 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#11 /app/web/core/lib/Drupal/Core/Render/Renderer.php(578): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#13 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#14 /app/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /app/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#16 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/web/core/lib/Drupal/Core/DrupalKernel.php(717): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#25 {main}

Steps to reproduce

On a fresh install with:
- entity_redirect either 2.0 or 2.x-dev
- commerce_order 2.27 (from commerce)
- drupal 9.2.13

Then go to /admin/commerce/config/order-types/default/edit and save.

I'm not sure if the problem comes from entity_redirect or commerce.
But I do see a 'entity_redirect' value at the top of $parents fed into NestedArray::setValue(), which makes me think it is the former :P

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France fougere

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    The problem comes from entity_redirect's use of the generically named element "workflow" when it injects itself into other modules forms. Any module with a bundle entity type form that already has an element of that name will throw a PHP exception on save. The element name "workflow" is commonly used by modules that use the Workflows module or workflow in general, such as Drupal Commerce. To solve this, please change the module to use a unique element name such as "entity_redirect_workflow" instead of just "workflow" in entity_redirect.module.

  • πŸ‡΅πŸ‡ΉPortugal adaragao

    Had this same problem with the module "Entity Registration", had to unnistall this module to work.

    Its related to https://www.drupal.org/project/registration/issues/3352096 πŸ’¬ PHP exception when saving a registration type and entity_redirect module is enabled Closed: works as designed

    Here is the backtrace:

    TypeError: Cannot assign array to property Drupal\registration\Entity\RegistrationType::$workflow of type string em Drupal\Core\Config\Entity\ConfigEntityBase->set() (linha 169 de /opt/drupal/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).

    Backtrace
    #0 /opt/drupal/web/core/lib/Drupal/Core/Entity/EntityForm.php(341): Drupal\Core\Config\Entity\ConfigEntityBase->set()
    #1 /opt/drupal/web/core/lib/Drupal/Core/Entity/EntityForm.php(301): Drupal\Core\Entity\EntityForm->copyFormValuesToEntity()
    #2 /opt/drupal/web/core/lib/Drupal/Core/Entity/EntityForm.php(171): Drupal\Core\Entity\EntityForm->buildEntity()
    #3 [internal function]: Drupal\Core\Entity\EntityForm->afterBuild()
    #4 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(1084): call_user_func_array()
    #5 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(579): Drupal\Core\Form\FormBuilder->doBuildForm()
    #6 /opt/drupal/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm()
    #7 /opt/drupal/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
    #8 /opt/drupal/web/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult()
    #9 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
    #10 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #11 /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #12 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
    #13 /opt/drupal/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #14 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #15 /opt/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #16 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #17 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #18 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #19 /opt/drupal/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
    #20 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
    #21 /opt/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #22 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #23 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #24 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #25 /opt/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
    #26 /opt/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
    #27 /opt/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #28 {main}

Production build 0.71.5 2024