Problem/Motivation
Found in #2946333: Allow synced Layout override Translations: translating labels and inline blocks
It is more obvious in that issue but it can be reproduced without that patch.
- Create a view that list all non-reuseable blocks and links to the block(will open edit)
- Create an inline block
- Save the layout
- goto the view. Update the inline block
- Try to edit the block in the layout builder.
- Get an error
This is because \Drupal\layout_builder\Plugin\Block\InlineBlock stores the revision id. and loads the block for editing.
If the block is only edited in Layout Builder it will always be the latest revision. If it is edited outside of layout builder it will not be the latest revision.
This is an edge-case now but in [# #2946333: Allow synced Layout override Translations: translating labels and inline blocks this will be a problem because translation will store translations of inline blocks so they will create new revisions of the blocks.
Proposed resolution
Use \Drupal\Core\Entity\EntityRepositoryInterface::getActive() in \Drupal\layout_builder\Plugin\Block\InlineBlock::blockForm() to get the revision that can be edited
Remaining tasks
Do it
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3052042-8.patch | 5.03 KB | ashwinsh |
| #7 | 3052042-7.patch | 4.9 KB | tedbow |
| #7 | interdiff-5-7.txt | 697 bytes | tedbow |
| #5 | 3052042-5.patch | 4.92 KB | tedbow |
| #5 | 3052042-5-TEST_ONLY.patch | 1.64 KB | tedbow |
Comments
Comment #2
tedbowHere is fix that loads the active revision and test.
Comment #3
tedbowwhoops I deleted the drupalGet() that loaded the block edit page. This only didn't fail because the current page also had a "Save" button. Fix this and added the assert for the save message text.
Comment #5
tedbow😔
url()is deprecated.Comment #7
tedbowWe actually only need to test here if
!$block->isNew()Otherwise we can get the active block for editing.Comment #8
sam152 commentedNW for the same reasons I described in the translation issue.
Comment #9
acbramley commentedMy 2c - inline blocks shouldn't be editable through the UI to begin with #3075308: Inline blocks shouldn't be editable via the normal block content UI would love some feedback!
Comment #10
chris burge commentedThe ability to edit inline blocks outside of Layout Builder would provide UX benefits. The ability to edit via a contextual link is a good example: #3020876: Contextual links of reusable content blocks are not displayed when rendering entities built via Layout Builder
Comment left over at #3075308: Inline blocks shouldn't be editable via the normal block content UI
Comment #12
sam152 commentedI posted this in the translation issue, but using any revision other than the one stored in the host entity causes data integrity issues and data loss when used in combination with the "Revert revision" button that is available and has likely been pressed a whole bunch of times already. See the following issue for a deeper explanation: #3053881: Reverting entity revisions that contain custom blocks erroneously triggers EntityChangedConstraint
Since working on those issues, I haven't had any discussions to suggest that this issue should be closed in favour of #3075308: Inline blocks shouldn't be editable via the normal block content UI. Editing inline blocks outside of the LB interface needs to be explicitly denied.
@tedbow, if you feel differently feel free to reopen this or comment on any of the other data integrity issues.
Comment #13
chris burge commentedThis issue directly affects the feasibility of reusable blocks that can be edited in Layout Builder: #2999491: Add reusable option to inline block creation. Reusable inline blocks is basically the same problem solved in D7 by Fieldable Panels Panes with reusuable panes. The fate of this issue is tied to #2999491: Add reusable option to inline block creation.
Comment #14
ashwinshBased on https://www.drupal.org/project/layout_builder_st/issues/3067646 reference, I have updated this patch.