Problem/Motivation
Once #2907413: Consider supporting Layout Builder Overrides for other view modes is addressed, sections will be stored per-view mode.
LayoutEntityHelperTrait::getEntitySections() assumes the view mode is default.
Proposed resolution
Provide additional functionality for displays, and do not assume the default display.
Remaining tasks
Thank you all! Sadly still needs tests and steps to reproduce to be committed. I don't have the time currently, sorry.
Steps to reproduce should follow, per #3008924-13: Callers of LayoutEntityHelperTrait::getEntitySections() do not account for the view mode:
Could you explain how to reproduce the bug, using only core modules?
Step by step, starting with "Install standard profile"
That is an important step for writing test coverage, which must be done before the fix can be committed.
User interface changes
N/A
API changes
TBD
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | 3008924-42.patch | 1.95 KB | andypost |
Issue fork drupal-3008924
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 #3
tim.plunkettComment #4
matt_paz commentedThanks for the work on this.
After a bit of debugging, I think this issue (#3008924) might be why I'm getting an error from quickedit.
I'm using display_mode_extras and on the surface, LB seems to be presenting different layouts correctly (so far).
I only saw one side-effect:
/quickedit/metadata
---
It looked like ...
web/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
$sections = $this->getEntitySections($entity);... was indeed only returning the `default` display mode.
That got me worried, tho. Is this the only side-effect, or might be other, ugly side-effects that I haven't seen yet.
Do you think I'm good to continue using LB with other display modes in the interim, or would you advise against it (until #3008924 gets fixed) for reasons that haven't jumped out at me yet? It seems like comments in #2907413 were advising that different view modes shouldn't be supported at all. If that's looking like the direction this will be heading, please advise.
While it _mostly_ seems to be working for me, I'd just assume drop use of display_mode_extras, step back and think through other ways to facilitate what I was looking at doing if this isn't likely to get addressed.
Comment #5
romixuaI revived error during of reproducing of this issue https://www.drupal.org/project/field_formatter_class/issues/3053629
So after debuging and investigation I find that we always use view mode 'full'
In my case I need to get section storage for teaser, and than get component by UUID, but we get the exception that UUID is invalid.
Here is the patch that resolve this problem. Using of additional argument with default value fix the problem, and prevent errors after code changes.
Comment #6
matt_paz commentedThe patch from #5 seemed to resolve the issues reported in #4 as well. Thanks @Romixua!
Comment #7
pifagor commentedComment #8
anybodySame problem as in #4, fixed by #5! We're using it in Drupal 8.7.x
Wonderful! RTBC +1.
I guess @tim.plunkett should do the final RTBC?
Comment #10
yepaSame fatal error on a project based on drupal 8.7.5.
InvalidArgumentException: Invalid UUID "3b59df4b-cf9a-4347-af9d-36036d93c9a7" in Drupal\layout_builder\Section->getComponent() (line 177 of web/core/modules/layout_builder/src/Section.php).The patch #5 works fine! Thanks @Romixua
Comment #11
tim.plunkettThanks for the patch! That looks like a good fix.
Before it is committed, we need test coverage of the existing bug that fails, and then passes when combined with this change.
Comment #12
maskedjellybean#5 works in Drupal 8.8.1.
I was seeing this error after moving a block in Layout Builder from one section to a new section and then trying to delete the old section. This patch allows me to do this without errors.
Comment #13
tim.plunkett@matt_paz, @Romixua, @Anybody, @yepa, @maskedjellybean:
Could you explain how to reproduce the bug, using only core modules?
Step by step, starting with "Install standard profile"
That is an important step for writing test coverage, which must be done before the fix can be committed.
Thanks!
Comment #15
abhisekmazumdarSo the #5 works for me.
I came across this issue when I was trying to alter the view mode of a content type which uses layout builder for display.
Comment #16
phjouThe patch in #5 seems to work for me as well. But the issue was not with quick_edit but with a computed field.
Comment #17
Vidushi Mehta commentedI've pulled the latest code and the patch #5 was failed to apply. Added a rerolled patch against 9.1.x.
Comment #18
WebbehReiterating comment #13:
I was unable to reproduce this issue from a fresh 9.1.x install, without and with field_formatter_class.
I attached a View block of entities' teaser displays into a (separate entity type) Layout, which worked as expected and without the reported issue.
+1 to getting a repeatable process to recreate and resolve this bug.
Comment #20
simgui8 commented#17 fixes it for me on drupal 8.9.7
The site that had this error uses the field_formatter_class module.
Comment #22
murzI catch this problem on my website even without field_formatter_class module, or any other similar module for formatting fields, the error on Drupal 9.2.4 is:
Uncaught PHP Exception InvalidArgumentException: "Invalid UUID "xxx"" at web/core/modules/layout_builder/src/Section.php line 184And the patch form #17 resolves the fatal error for me, thanks!
Comment #24
geoffreyr commentedRerolled against 9.3.x.
Comment #27
anybodyThank you all! Sadly still needs tests and steps to reproduce to be committed. I don't have the time currently, sorry.
But I can confirm it works great, we're using it in several projects for a long period of time.
Comment #28
anybodyImportant:
#3044993: Allow synced Layout default Translations: translating labels and inline blocks uses
$this->getSectionStorageForEntity($this->entity);inSo I guess it's relevant for that issue to fix the hard coded view mode as translations may differ per view mode!
Comment #30
anybodyPatch fails to apply against 9.4.2. Both the MR and the rerolled patch from #24.
Comment #31
anybodyThe reason is that
function getQuickEditSectionComponent()has been removed in 9.4.x.Comment #32
anybody@hswong3i could you please change the MR to point against 9.5.x? It seems I can't do that.
BTW I still couldn't figure out how to reproduce this on a clean install, but ran into it again and again in several existing installations.
Comment #33
diegodalr3 commentedPatch updated to apply on Layout Builder and QuickEdit modules.
Related change https://www.drupal.org/node/3265518
Comment #35
anybodyCreated a new MR against 9.5.x as I couldn't change the target branch in the existing and there was no reaction from @hswong3i. And rebasing issue forks is still kind of pain or perhaps I'm just too dumb ;)
Comment #37
andrea.cividini commented+1 for patch #33 on Drupal 9.4.3 / PHP 7.4
Comment #38
WebbehThis needs an issue summary update for our progress and next steps, as I think some comments may be missing what work is left.
From #27:
Have we made progress on either/both? If so, I'll move back to For Review.
Comment #39
WebbehUpdated IS where we're at.
Comment #41
a.milkovskyThe changes in the merge request 2499 work great for me against 9.5.x.
Unfortunately the patch does not apply against 10.1.x.
Comment #42
andypostPatch for 10.1.x, queckedit moved to contrib
Comment #43
hfernandes commented#42 worked here. Even though I'm using Drupal 9.5.
Comment #44
smustgrave commentedDid not test
But for the tests and steps to reproduce.
Comment #46
joelpittetWe've been using #33 for a while. Thanks for rerolling @andypost.
Sorry I don't have any steps on this one, but my guess it has to do with our entity references to field_bundle/storage entities in LB.
Comment #48
carolpettirossi commentedI have faced an issue that I needed to add patch #42 + patch from https://www.drupal.org/project/layout_builder_st/issues/3069964 when using the modules "Moderation Dashboard" and accessing the /user/{uid}/moderation-dashboard page.
Comment #50
anybodyEdit: Sorry comment was wrong.