Problem/Motivation
After updating Mercury Editor from 3.0.0-alpha13 to 3.0.0-alpha14, editing content results in a fatal error.
The editor UI loads, but the page rendering fails with:
Error: Call to a member function getSetting() on null
in mercury_editor_entity_display_build_alter()The issue occurs when rendering entities using Layout Builder.
Steps to reproduce
- Install Drupal (tested with Drupal 10)
-
Install and enable:
- Mercury Editor
- Layout Builder
- Use Gin as the admin theme
-
Update Mercury Editor:
composer require drupal/mercury_editor:^3.0@alpha14 - Clear cache
- Edit a node with Mercury Editor
Result: Fatal error.
Error: Call to a member function getSetting() on null
in mercury_editor_entity_display_build_alter()
(line 308 of modules/contrib/mercury_editor/mercury_editor.module)
Stack trace begins:
Error message
#0 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): mercury_editor_entity_display_build_alter()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php(289): Drupal\Core\Extension\ModuleHandler->alter()
#2 /var/www/html/web/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php(282): Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple()
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(340): Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple()
#4 /var/www/html/web/core/modules/node/src/NodeViewBuilder.php(24): Drupal\Core\Entity\EntityViewBuilder->buildComponents()
#5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(282): Drupal\node\NodeViewBuilder->buildComponents()
#6 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(239): Drupal\Core\Entity\EntityViewBuilder->buildMultiple()
#7 [internal function]: Drupal\Core\Entity\EntityViewBuilder->build()
#8 /var/www/html/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(113): call_user_func_array()
#9 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(886): Drupal\Core\Render\Renderer->doTrustedCallback()
#10 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(431): Drupal\Core\Render\Renderer->doCallback()
#11 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(248): Drupal\Core\Render\Renderer->doRender()
#12 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(238): Drupal\Core\Render\Renderer->render()
#13 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(637): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#14 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(231): Drupal\Core\Render\Renderer->executeInRenderContext()
#15 /var/www/html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare()
#16 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
#17 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
#18 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#19 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#20 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#21 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#23 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#24 /var/www/html/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#25 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#26 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#27 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#28 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#29 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#30 /var/www/html/web/modules/contrib/mercury_editor/src/StackMiddleware/AjaxPageState.php(38): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#31 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\mercury_editor\StackMiddleware\AjaxPageState->handle()
#32 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#33 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#34 {main}
Expected behavior
The editor should render normally without fatal errors.
Actual behavior
Page rendering fails with a fatal error when getSetting() is called on a null object inside mercury_editor_entity_display_build_alter().
System information
Drupal version
Drupal 10.x
Mercury Editor
3.0.0-alpha14
Admin theme
Gin
PHP version
8.3
Environment
DDEV
Possible cause
The error indicates that $component or a related object is NULL before getSetting() is called.
It appears that alpha14 introduced a change in the entity display alter logic, possibly related to Layout Builder integration.
Temporary workaround
Downgrading fixes the issue:
composer require drupal/mercury_editor:^3.0@alpha13
Issue fork mercury_editor-3577871
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3577871-error-call-to-3x
changes, plain diff MR !146
- 3577871-error-call-to
changes, plain diff MR !145
Comments
Comment #2
szeberli commentedComment #5
rohit rana commented@szeberli please review
Comment #6
szeberli commentedThank you for the patch and the merge request. The change seems reasonable to me. However, the merge request was made against 2.1.x. This is probably a mistake. The issue concerns the 3.0.x branch. Please submit a new MR. I will be happy to review it.
Comment #8
rohit rana commented@szeberli please review
Comment #9
szeberli commentedHello,
Thank you for the change, the error has disappeared for me.
Comment #12
bramdriesenRTBC +1
Comment #14
justin2pin commented