Steps to reproduce
Drupal 9.3.2, with Layout Builder and Display Suite 8.x-3.13 enabled.
I've choose a DisplaySuite layout in a content form display.
Then, I cant' display content.
Problem/Motivation
Error: Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isLayoutBuilderEnabled() in Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->isLayoutBuilderEnabled() (line 330 of core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php).
Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->isLayoutBuilderEnabled() (Line: 382)
Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->access() (Line: 362)
Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage->access() (Line: 37)
Drupal\layout_builder\Access\LayoutBuilderAccessCheck->access()
....
Proposed resolution
To work around the problem, not being a Drupal developer, I simply added the missing method such as:
namespace Drupal\Core\Entity\Entity;
...
class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayInterface {
...
public function isLayoutBuilderEnabled() {
return \Drupal::moduleHandler()->moduleExists('layout_builder') ;
}
...
}
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3277728-7.patch | 792 bytes | eleonel |
Issue fork drupal-3277728
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
Comment #2
larowlanCan you please provide steps to reproduce the issue starting from 'install drupal' - thanks
Comment #3
foxneil0912 commentedI have this exact error only when i have Layout Field module enabled. When i disable it -> error is gone
Comment #5
flyke commentedI have a site using LayoutBuilder wich was working without problem.
I then added a new content type for which I needed and enabled DisplaySuite to select a layout for the teasers of that content type.
That resulted in the error:
This can be fixed by editing
web/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.phpAnd changing:
Into:
My layoutbuilder page which uses a content block that renders a view of teasers (for which I needed Display Suite) is still blank.
So I guess the issue of LayoutBuilder and Display Suite not working together at all still remains. This only fixes that specific error but its a step in the right direction.
Comment #6
tim.plunkettDisplay Suite supposedly fixed this a couple years ago: #3054607: Layout builder incompatibility
Comment #7
eleonelI have the same problem using Drupal 9.4.4, with Layout Builder and Layout builder library 8.x-1.0-beta3.
Steps: Save a node (with layout builder configured for the node's content type) and it may result in a white screen and in the logs you may found the same error as described on the description of this issue.
I tried to solve the issue by patching layout_library module https://www.drupal.org/project/layout_library/issues/3306517
But I'm still getting the error, so I plan to use the attached patch (based on #5)until we/someone implement a better solution.
Comment #9
smustgrave commentedThis a problem with layout builder or layout builder library?
Will need a test case for core to show this problem.
Will leave in PNMI for a few more months before closing if no follow up.
Comment #10
danielvezaThis has been PNMI for 6 months now with no further issue reports, and we have no steps to reproduce with just core. Closing this issue now, if someone can replicate this with just core feel free to reopen.
Comment #11
alex.bukach commented@DanielVeza we faced the issue recently on several projects, with the patch #7 having resolved it.
Comment #12
smustgrave commentedSteps to reproduce will still need to be added to issue summary.
Bugs require test coverage.
Comment #13
danielvezaCould we please get a stacktrace as well?
Comment #14
kevinquillen commentedI am seeing a similar issue occur (Drupal 10.2.2). Occasionally when the cache clears (its not consistently happening), the entire site layout breaks and the PHP logs have this error:
Uncaught PHP Exception Error: "Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isOverridable()" at /var/www/html/docroot/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php line 312The error can persist through a few cache clears until it finally resolves itself. It should be noted we are using Memcache on Acquia, and this only happens in the production environment and never dev or stage.
The only LB related contributed modules we have are:
This issue can then cascade down and cause other errors that are not real, like other core classes not existing (when they do). Once the cache is completely purged and rebuilt, its fine.
(unfortunately no stack trace logs for Acquia and the error is not visible on the site when it happens)
Comment #15
kevinquillen commentedHappened again today, even with the adapted patch above for isOverridable and isLayoutBuilderEnabled. Only this time, no logs. Again, only in prod. Running cron "corrected" the problem.
Our only other action here is removing Memcache on Acquia (Cloud Next) entirely and seeing if it persists.
Comment #16
kevinquillen commentedThis issue is still happening at random, even with Memcache disabled.
Should this even be possible at that point in the code in Layout Builder?
Uncaught PHP Exception Error: "Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isOverridable()" at /var/www/html/docroot/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php line 312That method is defined as:
getDisplay:
It says it should return an instance of LayoutEntityDisplayInterface, instead it returns an instance of EntityViewDisplay. Under what conditions could that happen? Trying to trace calls to isOverridable does not really produce much.
SectionStoragedefines its context definition as an entity view display:This is where the trail runs cold for me. Does anyone know how or when EntityViewDisplay could be returned instead of an expected LayoutEntityDisplayInterface object that triggers the error?
Comment #17
tim.plunkettWhat's the stack trace of the exception? Whatever it is, it's happening before
layout_builder_entity_type_alter()has run, which shouldn't be possible.Comment #18
danielveza@kevinquillen This may be unrelated, but the code you've posted for
DefaultsSectionStorage::isOverridableis different to cores. Is there a chance you have a patch that may be causing issues?Comment #19
kevinquillen commentedSorry, that was an error as I was trying a few things. Everything is removed now and back to
Comment #20
luke.leberI may have some tangentially related info here. We recently found that due to how layout builder works (prior to Drupal 10.3), the accumulation of derived field blocks resulted in a single cache item in `cache_discovery` having a size of over 6mb.
This _may_ result in extreme performance problems for memcache users, because the default config won't store individual items over 1mb in size.
Just a theory, but such a large, virtually uncatchable, record could explain a lot of the "this should not be able to happen under normal circumstances" responses to this issue. Systems break down in wild ways when the underlying infrastructure doesn't behave as expected.
I'm curious if this happens in 10.3+ with most derived field blocks disabled so the block plugins CID falls below 1mb?
Comment #21
kevinquillen commentedI will add that we found this specific issue and error to happen far, far less with the application of this patch:
https://www.drupal.org/project/drupal/issues/3207813#comment-14380171
We then moved storage back from the database cache to memcache - but what Luke says in #20 is still true. We are still running Drupal 10.2.5.
I also found a way to replicate this issue:
I was able to get the behavior 90% of the time, which is why this was so hard to track down in prod. It was once in a blue moon where the caches would clear as site traffic was happening at the same time to a degree that would cause this. The main issue is a deadlock on the cache_config table, which breaks (seems to break) plugin discovery and cache builds. But if this is the case I do not think this is specifically a Layout Builder issue but something in core as the above patch alludes to, it just happens to affect Layout Builder.
These may also be related:
Comment #22
kevinquillen commentedThis thread seems close to the issue at hand:
https://www.drupal.org/project/shield/issues/3277210#comment-15083125
Comment #23
luke.leberPotentially related issue on the same note as #22, albeit not in Middleware, but a different service constructor.
Comment #24
lan commentedHello everyone,
I’ve been experiencing an issue related to Layout Builder on my site:
Error: Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isLayoutBuilderEnabled() in Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->isLayoutBuilderEnabled() (line 341 of docroot/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php).To address this, I applied the patch (in #7). However, after applying the patch, I am now encountering a new error (same as #16):
Error: Call to undefined method Drupal\Core\Entity\Entity\EntityViewDisplay::isOverridable() in Drupal\layout_builder\Plugin\SectionStorage\DefaultsSectionStorage->isOverridable() (line 318 of docroot/core/modules/layout_builder/src/Plugin/SectionStorage/DefaultsSectionStorage.php).My Drupal version is 10.3.1 with Layout Builder enabled. My site only has one content type using Layout Builder and does not heavily rely on this module.
Has anyone else faced a similar issue after applying this patch? If so, how did you resolve it? Any insights or suggestions would be greatly appreciated.
Thanks in advance for your help!
Comment #25
smustgrave commentedShould this be reopened this?
Comment #26
kevinquillen commented#24 was this of any help? #3277210: Shield middleware invokes hooks before modules are loaded, corrupting module_implements cache https://www.drupal.org/project/shield/issues/3277210#comment-15560180
Comment #27
smustgrave commentedWill say if this still happening lets put back into NW, but no follow up in 3 months could close out.
Comment #28
smustgrave commentedWanted to bump 1 more time.
Comment #29
anthonylindsay commentedFor what it's worth, we're seeing this issue now.
Happening on prod and dev environments, (mostly dev), not local.
Drupal 10.5.6
Redis
Layout builder and selected friends.
I _saw_ it on dev, and could not remedy it by any of
I got it to work once only by hitting
update.phpBut specifically clearing Redis made it work, and now, annoyingly I cannot recreate.
Comment #30
anthonylindsay commentedOK, after a few attempts, I can confirm that the method outlined in #21 works to replicate the problem, and flushing Redis rectifies it.
Comment #31
luke.leberWe just had another incident this morning that started when the hosting provider was performing Memcached maintenance during which a memcached reboot happened.
As Memcached was rebooted, an out of memory error occurred and as a result, it seems like cache corruption happened.
Comment #32
luke.leberMore technical info...this is how to reproduce the symptom:
With layout builder enabled, execute:
and observe that on the front-end all layout builder content disappears for anonymous users, and authenticated users face the exception detailed in the IS.
which should definitively prove that the cause of the symptom lies in the
discoverycache bin.The question is now how / why could the discovery cache bin be corrupted. Initial signs point to #3207813: ModuleHandler skips all hook implementations when invoked before the module files have been loaded, but I'm not convinced this is the only culprit, as our code-base has no inappropriate constructors about...
Comment #33
luke.leberThe next time this happens to anyone subscribing here, please run
drush php:eval "file_put_contents('/tmp/discovery-entity-type.txt', print_r(\Drupal::cache('discovery')->get('entity_type'), TRUE));"and share the contents of your discovery cache. This will greatly aid in figuring out exactly what the original cause was (i.e. no entity type alter hooks running, some hooks not running, or some other kind of undefined behavior).
The above snippet should work on all cache backends (including memcache).
Comment #36
luke.leberPushed a branch against 10.5.x for a possible production spy.
https://git.drupalcode.org/issue/drupal-3277728/-/compare/10.5.x...do-no...
Comment #37
luke.leberAdded acquia-specific production spy that reduces early bootstrap dependencies. All that's now needed from the container is the lock service, which is only dependent on the database service.
https://git.drupalcode.org/issue/drupal-3277728/-/compare/10.5.x...do-no...
To test beforehand...
AH_SITE_GROUP=myapp+AH_SITE_ENVIRONMENT=myenv/mnt/files/myapp.myenv/files-privatedrush si minimaldrush en layout_builderdrush pm:uninstall page_cachedrush sql:query "truncate cache_discovery;"layout_builder_entity_type_alterhook'[[SPLUNK ALERT]] - Request abandoned due to possible cache corruption; see /mnt/files/myapp.myenv/files-private/3207813-debugging.txt for details.'layout_builder_entity_type_alterhookTheoretically this should allow...
to happen in a relatively unattended fashion...although it still may take some time for the problem to actually manifest.
Comment #38
luke.leberRunning
drush php:eval "file_put_contents('/tmp/discovery-entity-type.txt', print_r(\Drupal::cache('discovery')->get('entity_type'), TRUE));"against a production Acquia environment while in a broken state yields an
entity_view_displayconfig object of...-- at least from the perspective of the SSH pod. There are caveats to this:
So in other words, even after collecting this diagnostic info, it's still unclear which layer is being corrupted, even if from the perspective of the SSH pod, "everything is fine".
It doesn't look like anything short of the spy from #36 or #37 will be able to shine any more light on this.