Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Adding a SystemMainBlock
to a layout builder layout causes a fatal error and renders the Manage layout page unusable.
Steps to reproduce
- Install core
- Install Layout Builder
- Visit
/admin/structure/types/manage/page/display
- Select the Use Layout Builder option and click Save
- Follow the Manage layout button
- Click Add block
- Add the Main page content block from the System category and click Add block (this will appear to do nothing)
- Click Save layout
- Follow the Manage layout button again
- 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.
Comment | File | Size | Author |
---|---|---|---|
#24 | 3218766-hide-main-content-24.patch | 1.39 KB | gabesullice |
#24 | interdiff-18-24.txt | 700 bytes | gabesullice |
#18 | 3218766-hide-main-content-18-PASS.patch | 1.39 KB | tim.plunkett |
#18 | 3218766-hide-main-content-18-FAIL.patch | 771 bytes | tim.plunkett |
#10 | original-stack-trace.txt | 2.52 KB | gabesullice |
Comments
Comment #2
WebbehI would assume this has to do with
, 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.
Comment #3
rossidrup CreditAttribution: rossidrup commentedI 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"
Comment #4
rossidrup CreditAttribution: rossidrup commentedI 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
Comment #5
WebbehClear your caches and run cron after the uninstall of Layout Paragraphs, and see if that fixes it.
Comment #6
rossidrup CreditAttribution: rossidrup commentedi 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
Comment #7
larowlanCan you provide steps to reproduce that start with 'install drupal'
Thanks
Comment #8
tim.plunkettThis is a duplicate of #3162699: Improve debugability of block plugins returning NULL in Layout Builder
Comment #9
gabesulliceI 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.
Comment #10
gabesulliceComment #11
rossidrup CreditAttribution: rossidrup commentedi told you and you did not believe me
Comment #12
WebbehThis 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.
Comment #13
cilefen CreditAttribution: cilefen as a volunteer commentedI'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.
Comment #14
rossidrup CreditAttribution: rossidrup commentedof 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.
Comment #15
larowlanThanks @gabesullice, this was the detail we needed
I think we can filter that block out using the existing plugin filters.
Comment #16
tim.plunkettSee also:
#2825497: SystemMainBlock only functions when used by block.module
#2885370: SystemMainBlock::build does not always return array
All closed in favor of
#3164389: Enforce block plugins returning an array
Comment #17
gabesulliceThanks @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?Comment #18
tim.plunkettI 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".Comment #19
gabesulliceHeh, 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?Comment #21
tim.plunkettThat'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.
Comment #22
rossidrup CreditAttribution: rossidrup commentedcan 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?
Comment #23
gabesulliceThanks @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:
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.
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.
Comment #24
gabesulliceFTFY ;)
Comment #26
larowlan🚀Committed df19e70 and pushed to 9.3.x. Thanks!
As there is little risk of disruption here, backported to 9.2.x