Problem/Motivation

Adding a SystemMainBlock to a layout builder layout causes a fatal error and renders the Manage layout page unusable.

Steps to reproduce

  1. Install core
  2. Install Layout Builder
  3. Visit /admin/structure/types/manage/page/display
  4. Select the Use Layout Builder option and click Save
  5. Follow the Manage layout button
  6. Click Add block
  7. Add the Main page content block from the System category and click Add block (this will appear to do nothing)
  8. Click Save layout
  9. Follow the Manage layout button again
  10. Observe a WSOD

The only way to recover the ability to manage layout is to deselect the Use Layout Builder option, save, and then re-enable it.

Orginal report

I just started using layout builder on local site; enabled it on page content type...also Installaed paragraphs and layout paragraphs module.
When i edit the content now and press layout button I get wsod and this is what is in the error logs.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rossidrup created an issue. See original summary.

Webbeh’s picture

Priority: Critical » Normal

I would assume this has to do with

also Installaed paragraphs and layout paragraphs module.

, and not with Layout Builder in Core (since this error will likely not occur if you were to re-do the process but do not install Layout Paragraphs).

Setting priority to Normal for this bug report.

rossidrup’s picture

I dont think it is true...I uninstalled layout paragraphs and tried to press layout button again under edit content

and get wsod again

and the error is stiil here

[14-Jun-2021 19:33:15] WARNING: [pool www] child 6606 said into stderr: "NOTICE: PHP message: TypeError: Argument 1 passed to Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() must be of the type array, null given, called in /var/www/html/web/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php on line 110 in /var/www/html/web/core/lib/Drupal/Core/Cache/CacheableMetadata.php on line 149 #0 /var/www/html/web/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php(110): Drupal\Core\Cache\CacheableMetadata::createFromRenderArray(NULL)"
[14-Jun-2021 19:33:15] WARNING: [pool www] child 6606 said into stderr: "#1 [internal function]: Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))"
[14-Jun-2021 19:33:15] WARNING: [pool www] child 6606 said into stderr: "#2 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Obj..."
2021/06/14 19:33:15 [error] 2018#2018: *5181 FastCGI sent in stderr: "PHP message: TypeError: Argument 1 passed to Drupal\Core\Cache\CacheableMetadata::createFromRenderArray() must be of the type array, null given, called in /var/www/html/web/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php on line 110 in /var/www/html/web/core/lib/Drupal/Core/Cache/CacheableMetadata.php on line 149 #0 /var/www/html/web/core/modules/layout_builder/src/EventSubscriber/BlockComponentRenderArray.php(110): Drupal\Core\Cache\CacheableMetadata::createFromRenderArray(NULL)
#1 [internal function]: Drupal\layout_builder\EventSubscriber\BlockComponentRenderArray->onBuildRender(Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#2 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent), 'section_compone...', Obj" while reading response header from upstream, client: 172.18.0.6, server: , request: "GET /node/1/layout HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "numerologija9.ddev.site", referrer: "https://numerologija9.ddev.site/node/1/edit"

rossidrup’s picture

I cant believe core layout module can be so buggy....
I think I got the same error 1 year ago which made me gave up on layout builder altogether....

I use local ddev installation....and am pretty good at Drupal...drupal is latest 9.1 version updated

Webbeh’s picture

Clear your caches and run cron after the uninstall of Layout Paragraphs, and see if that fixes it.

rossidrup’s picture

i had to delete that page content where I edited it....because layout button worked on other pages....only home was affected cause that is the only one i tested it on.....so that layout paragraphs is very dangerous seems to be.....
i did not run cron.....I guess that is too late now

larowlan’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

Can you provide steps to reproduce that start with 'install drupal'

Thanks

tim.plunkett’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)
gabesullice’s picture

Title: Layout builder error » Adding the <code>SystemMainBlock</code> to a layout builder layout causes a fatal error and renders the Manage layout page unusable.
Issue summary: View changes
Status: Closed (duplicate) » Active

I don't believe that this is a necessarily a duplicate. The referenced issue would certainly help to debug this, but I have replicated this on a fresh installation of Drupal core, which indicates an underlying core bug. I've added steps to reproduce to the original IS.

gabesullice’s picture

Title: Adding the <code>SystemMainBlock</code> to a layout builder layout causes a fatal error and renders the Manage layout page unusable. » Adding a SystemMainBlock to a layout builder layout causes a fatal error and renders the Manage layout page unusable.
Issue summary: View changes
FileSize
2.52 KB
rossidrup’s picture

i told you and you did not believe me

Webbeh’s picture

This was not that "people did not believe you", but the work to provide a step-by-step process to reproduce the issue (#3218766-9: Adding a SystemMainBlock to a layout builder layout causes a fatal error and should not be available) was crucial to help nail down the potential cause and source. See the request in #3218766-7: Adding a SystemMainBlock to a layout builder layout causes a fatal error and should not be available asking explicitly for that for help on determining a potential cause.

Thank you for the detailed reproduction steps, #9.

cilefen’s picture

I'll remind anyone that feels mistreated that this community values collaboration. If a maintainer asks for information and that information is not given then reporters do not have the right to feel mistreated.

rossidrup’s picture

of course, I dont feel mistreated....but sometimes it is hard to be more specific that I were. I gave you all the steps I did.
So what is the fix? Will you include the fix in next drupal update because for some reason I cant use layouts at all.

larowlan’s picture

Thanks @gabesullice, this was the detail we needed

I think we can filter that block out using the existing plugin filters.

tim.plunkett’s picture

gabesullice’s picture

Thanks @tim.plunkett! Now I'm on board with considering this a duplicate. #3164389: Enforce block plugins returning an array seems like it addresses the root cause. That said, does it ever make sense to place SystemMainBlock w/ Layout Builder? If not, is there already an issue for filtering it out as suggested in #15? If not, should we keep this open for that?

tim.plunkett’s picture

Title: Adding a SystemMainBlock to a layout builder layout causes a fatal error and renders the Manage layout page unusable. » Adding a SystemMainBlock to a layout builder layout causes a fatal error and should not be available
Version: 9.2.x-dev » 9.3.x-dev
Status: Active » Needs review
FileSize
771 bytes
1.39 KB

I think that I picked the wrong issue in #8 when I closed this. That debuggability one is a nice to have, but yeah the enforcing return array is definitely the right one.

That said, in #3029819: Do not allow Page Title block to be placed in Layout Builder until it works properly we hid the Page Title block for the same reason as Main Content needs to be hidden, but I don't know why this one never came up.
There's definitely no reason to use that block in Layout Builder.
The good news is that layout_builder_plugin_filter_block__layout_builder_alter() already exists and is the exact place this could be "fixed".

gabesullice’s picture

+++ b/core/modules/layout_builder/layout_builder.module
@@ -233,6 +233,7 @@ function layout_builder_cron() {
+  unset($definitions['system_main_block'];

Heh, well that was easy!

I would have expected system module to remove its own block. What's the norm here? Is it common practice to have one core module hide another core module's stuff?

The last submitted patch, 18: 3218766-hide-main-content-18-FAIL.patch, failed testing. View results

tim.plunkett’s picture

That's a tricky question, made more complicated by the fact that it's system.module. Typically, I would say that core modules should provide their own integration with other core modules. But AFAIK we usually don't do that for system.
Also, in the case of page title, local actions, and local menu, those are provided by \Drupal\Core, not any particular module. I'm not sure why this one is provided by system, that's some historical weirdness.
Finally, I think regardless of where the alter lives, we already have the perfect place for the test coverage, and that's in LB.

All this to say, I think it's fine to keep this in layout_builder.module's hook.

rossidrup’s picture

can somebody explain why that happened on my site? And how to prevent it...or is just unpreventable.....I used the module like others did or not?

gabesullice’s picture

Thanks @tim.plunkett, that makes sense.


@rossidrup, we do not have enough information to explain what happened on your site. See #7 and #12. In #9, I added steps to recover from the error to the issue summary:

The only way to recover the ability to manage layout is to deselect the Use Layout Builder option, save, and then re-enable it.

Follow those steps and I think you will no longer see the error.

We believe that we have identified a number of Drupal core issues which would prevent your site from encountering the error again or, at minimum, provide you with some additional debugging information. @tim.plunkett created a patch for that in #18 and also linked to a number of related issues and patches that may help your specific situation.

I used the module like others did or not?

Yes, this is probably the case. Thank you for reporting the error so that this doesn't happen to anyone else in the future. If you can recover from the error, then recreate the error and tell us what steps you took in great detail, then we might be able to deduce what your site's specific problem was. Otherwise, we've made our best guess and cannot provide any more assistance. Please remember that we are a community of volunteers, not professional support staff. We have no ability to look at your site specifically and/or understand the specifics of your situation unless you provide the background information we need/ask for.

gabesullice’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
700 bytes
1.39 KB

FTFY ;)

  • larowlan committed 01fcb8d on 9.2.x
    Issue #3218766 by tim.plunkett, gabesullice: Adding a SystemMainBlock to...
  • larowlan committed df19e70 on 9.3.x
    Issue #3218766 by tim.plunkett, gabesullice: Adding a SystemMainBlock to...
larowlan’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed

🚀Committed df19e70 and pushed to 9.3.x. Thanks!

As there is little risk of disruption here, backported to 9.2.x

Status: Fixed » Closed (fixed)

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