Warning: Array to string conversion in Drupal\eca_modeller_bpmn\ModellerBpmnBase->optionsField()

Created on 28 February 2025, 2 days ago

Problem/Motivation

Got a lot of warnings when editing any model.

Warning: Array to string conversion in Drupal\eca_modeller_bpmn\ModellerBpmnBase->optionsField() (line 920 of eca/modules/modeller_bpmn/src/ModellerBpmnBase.php)

Steps to reproduce

Just edit any existing ECA model.

Here is some stack.

#0 /core/includes/bootstrap.inc(166): _drupal_error_handler_real()
#1 /modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php(920): _drupal_error_handler()
#2 /modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php(852): Drupal\eca_modeller_bpmn\ModellerBpmnBase->optionsField()
#3 /modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php(655): Drupal\eca_modeller_bpmn\ModellerBpmnBase->prepareConfigFields()
#4 /modules/contrib/eca/modules/modeller_bpmn/src/ModellerBpmnBase.php(610): Drupal\eca_modeller_bpmn\ModellerBpmnBase->properties()
#5 /modules/contrib/bpmn_io/src/Plugin/ECA/Modeller/BpmnIo.php(106): Drupal\eca_modeller_bpmn\ModellerBpmnBase->getTemplates()
#6 /modules/contrib/bpmn_io/src/Plugin/ECA/Modeller/BpmnIo.php(67): Drupal\bpmn_io\Plugin\ECA\Modeller\BpmnIo->build()
#7 /modules/contrib/eca/modules/ui/src/Controller/EcaController.php(208): Drupal\bpmn_io\Plugin\ECA\Modeller\BpmnIo->edit()
#8 [internal function]: Drupal\eca_ui\Controller\EcaController->edit()
#9 /core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#10 /core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#12 /core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#13 /var/www/clients/client1/web39/web/repos/ccmar/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /var/www/clients/client1/web39/web/repos/ccmar/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#15 /core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#16 /core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#17 /core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#18 /core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#19 /core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#20 /core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#21 /core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#22 /core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#23 /core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#24 /core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#25 /modules/contrib/remove_http_headers/src/StackMiddleware/RemoveHttpHeadersMiddleware.php(49): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#26 /core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle()
#27 /core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#28 /index.php(19): Drupal\Core\DrupalKernel->handle()
#29 {main}
🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇵🇹Portugal jrochate

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

Merge Requests

Comments & Activities

  • Issue created by @jrochate
  • 🇩🇪Germany jurgenhaas Gottmadingen

    There must be a plugin from a third-party module that has a configuration form with some unsupported components in it. This certainly not a bug in ECA. Can you please debug this further on your site to find out which plugin is causing this?

  • 🇵🇹Portugal jrochate

    Ok, will do so. I will get back here with more info.

    thanks.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    @tetatu thanks for the hint. That's brand new then. Just checked, and they have a new plugin to find entities.

    That has $entity_types[$entity_type->getProvider()][$machine_name] = $entity_type->getLabel(); in line 386 of \Drupal\tamper\Plugin\Tamper\EntityFinder::getEntityTypes. That label turns out to be a renderable array. They should turn that into a string, since this is used as an option in a select field. Would anyone mind reporting that in the tamper module? I'm away from the desk today.

  • 🇵🇹Portugal jrochate

    In my case, the $entity_type->getLabel() does return a string.

    Maybe there something else on the structure. I will take a look on Monday.

  • I uninstalled ECA and all its dependencies, because Composer wouldn't let me uninstall the new version of Tamper. Then I managed to uninstall it. Then I reinstalled ECA, then the previous version of Tamper, but even though I specify the exact previous version

    composer require 'drupal/tamper:^1.0@alpha'

    Composer installs the latest one, so I can't 100% verify that this module is causing the problem.

  • 🇵🇹Portugal jrochate

    I think the problem is near,. because if I invalidate the getLabel with a forced PHP error, por exemple using implode(), then the warnings go away.

    To get more deep on this, I will join my colleague on Monday to trace the code and be sure about it.

  • https://www.drupal.org/project/tamper/issues/3509682 🐛 Array to string Active

  • 🇵🇹Portugal jrochate

    I think you should improve that issue and try to explain a little more why you think an ECA error message is related to tamper :)

  • 🇩🇪Germany jurgenhaas Gottmadingen

    The plugin I mentioned in #5 has a list of entity types in a select field and the values in the options come across as arrays. If you remove that plugin, flush the cache and retry, the problem is gone.

  • 🇳🇱Netherlands megachriz

    Can it be that there exists a content entity type here that violates \Drupal\Core\Entity\EntityInterface contract? Allowed return types for \Drupal\Core\Entity\EntityInterface::label() are string, \Drupal\Core\StringTranslation\TranslatableMarkup or null.

    With the entity types I tested, all labels are instances of \Drupal\Core\StringTranslation\TranslatableMarkup.

    It is the case that \Drupal\tamper\Plugin\Tamper\EntityFinder::getEntityTypes() returns a multidimensional array, but this is intentional. The list of content entity types are grouped by provider:
    $entity_types[$entity_type->getProvider()][$machine_name] = $entity_type->getLabel();

    This makes it easier to find the content entity type that you want to use:

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Thank you @megachriz, that's exactly what's happening. As the JavaScript-based property panel in BPMN doesn't know anything about the Drupal Form API, we need to recognize this special case and convert that nested array into something that a simple html select understands. Will provide an MR for.

  • 🇵🇹Portugal jrochate

    Awesome. I'm ready to test that MR when it's available .

    • jurgenhaas committed 5a40261a on 2.1.x
      Issue #3509627 by megachriz, jrochate, jurgenhaas, tetatu: Warning:...
    • jurgenhaas committed fbbba2c9 on 2.1.x
      Revert "Issue #3509627 by megachriz, jrochate, jurgenhaas, tetatu:...
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Here you go.

  • Pipeline finished with Success
    about 9 hours ago
    Total: 478s
    #437955
  • 🇨🇦Canada chrisck BC, Canada

    The warnings are gone after applying the MR to the latest dev release 2.1.x-dev.

  • 🇵🇹Portugal jrochate

    There are no more PHP warnings when editing ECA model, and the select box with Entities still show the flat list with all of them.

    Thanks!

Production build 0.71.5 2024