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

  1. Install Drupal (tested with Drupal 10)
  2. Install and enable:
    • Mercury Editor
    • Layout Builder
  3. Use Gin as the admin theme
  4. Update Mercury Editor:
    composer require drupal/mercury_editor:^3.0@alpha14
  5. Clear cache
  6. 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

Command icon 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:

Comments

szeberli created an issue. See original summary.

szeberli’s picture

Issue summary: View changes

rohit rana made their first commit to this issue’s fork.

rohit rana’s picture

Status: Active » Needs review

@szeberli please review

szeberli’s picture

Status: Needs review » Needs work

Thank 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.

rohit rana’s picture

Status: Needs work » Needs review

@szeberli please review

szeberli’s picture

Status: Needs review » Reviewed & tested by the community

Hello,
Thank you for the change, the error has disappeared for me.

piridium changed the visibility of the branch 3577871-error-call-to to hidden.

bramdriesen made their first commit to this issue’s fork.

bramdriesen’s picture

RTBC +1

justin2pin made their first commit to this issue’s fork.

justin2pin’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.