Problem/Motivation
The revision log message form component is missing from the override layout entity form.
This is happening because Drupal\layout_builder\Form\OverridesEntityForm::init() currently uses Drupal\Core\Entity\Entity\EntityFormDisplay::collectRenderDisplay() with the $default_fallback parameter set to FALSE to load the entity $form_display. This removes the original components of the entity display form which includes the revision_log component.
Proposed resolution
- Update
Drupal\layout_builder\Form\OverridesEntityForm::init()to add the revision_log_message_form_item component to the entity $form_display ifContentEntityForm::showRevisionUi()isTRUE. - Add test(s).
Remaining tasks
Answer #36.2
User interface changes
Revision log message form is displayed on layout override form for entity types that support revisioning.
API changes
None.
Data model changes
None.
Release notes snippet
Update Layout Builder entity overrides form to display revision log message form when appropriate.
Original report by johnwebdev
With #3004536: Move the Layout Builder UI into an entity form for better integration with other content authoring modules and core features now being committed we have the Revision UI in the Layout Builder UI and when you save an override layout a new revision is created.
However, if you untick the "Create new revision" checkbox, a new revision is created anyway.
Secondly, you're not able to write a revision message.

| Comment | File | Size | Author |
|---|---|---|---|
| #55 | 3033516-nr-bot.txt | 2.33 KB | needs-review-queue-bot |
| #48 | 3033516-48.patch | 4.64 KB | ravi.shankar |
Issue fork drupal-3033516
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:
- 3033516-revision-ui-on
changes, plain diff MR !649
Comments
Comment #2
johnwebdev commentedMe and phenaproxima manually tested this in #2937199: Track Layout override revisions on entities which support revisioning today, closing this issue as 'cannot reproduce'.
Comment #3
mrweiner commentedRe-opening as I'm experiencing the same issue where there is no revision log field is present at all. Furthermore I opened up a Drupal Answers post and received confirmation of the bug from a user over there:
The distribution noted above is the Lightning Distro, but that doesn't appear to be the culprit. Marking Major as it completely breaks revisions related to Layout Builder.
Comment #4
ismail cherri commentedI think I found the source of this bug.
In Drupal\layout_builder\Form\OverridesEntityForm class, the init() loads the entity $form_display using collectRenderDisplay method with the default_fallback set to FALSE, thus it removes the original components of the Node Display Form including the 'revision_log' component.
I think at this stage, the OverridesEntityForm should check if the entity implements \Drupal\Core\Entity\RevisionLogInterface and accordingly sets the component for 'revision_log'.
Comment #5
twfahey commentedThis patch I believe needs some work, but it is working for me on node entities, to add the log message when creating layout.
Comment #7
tim.plunkettOh I wish we'd had test coverage. This was definitely working before, but that change to collectRenderDisplay indeed broke it.
One note:
$form_state->getBuildInfo()['callback_object']is equivalent to$thishere, so this can be$section_storage = $this->getSectionStorage();Comment #8
twfahey commentedCool - as Ismail Cherri pointed out, we should check to see that the entity type is revisionable, so added that check in using the `isRevisionable()` method, which I *think* we can rely safely on here.
Comment #9
ismail cherri commented@twfahey If I may add, I don't think you need to get the Entity through the section storage at this point because
$this->entityis already defined and it is used before your added code.Comment #10
twfahey commentedGood call - simplified in latest patch, and adding initial testing.
Comment #11
twfahey commentedCleaned up from last patch.
Comment #12
twfahey commentedRemove unused modules and body.
Comment #13
twfahey commentedComment #14
twfahey commentedRealized I wasn't asserting the block text had reverted back to the original text.
Comment #15
borisson_Setting this back to needs work for the nitpick, but I could only find that really small issue here, overall this is looking really good and it looks like it has sufficient (functional) coverage.
Übernit: this adds unneeded whitespace at the end of the line, can we remove that?
Comment #16
yogeshmpawarComment #17
yogeshmpawarComments addressed in #15 & added an interdiff as well.
Comment #18
borisson_Removed the needs tests tag because it seems like there is sufficient coverage now. My only nitpick also has been resolved.
Comment #19
adam-delaney commentedThis patch works as expected. Applied cleanly against core 8.7.3.
Comment #20
tim.plunkettThe getRevisionMetadataKey method is only on
\Drupal\Core\Entity\ContentEntityTypeInterfaceso in theory this needs an instanceof check...The isRevisionable check worries me. It shouldn't be necessary if there's a revision metadata key. Also, are we sure this is all that is needed? Are there more checks needed?
Will this respect the individual options as set up in the baseFieldDefinitions methods? For example, MenuLinkContent hides this
Comment #21
alexpottLooks like we need answers to #20.
Comment #22
tim.plunkettComment #25
joegraduateComment #26
joegraduateThe attached patch addresses the questions/concerns raised by @tim.plunkett in #20:
Added instanceof check.
Replaced isRevisionable() with showRevisionUi() which also checks the $show_revision_ui property on the EntityType plugin.
I believe using showRevisionUi() instead of isRevisionable() should prevent this from doing anything for EntityType plugins like MenuLinkContent that haven't explicitly enabled the $show_revision_ui property.
Comment #28
joegraduateComment #29
joegraduateComment #30
joegraduateAdded defaultTheme property and setup method return typehint to LayoutBuilderRevisionTest.
Comment #31
johnwebdev commentedI think we need a issue summary update here.
Comment #33
james hawthorn-byng commentedPatch from comment #30 works for me
Comment #35
luke.leber+1 for #30
Comment #36
tim.plunkettThis form extends ContentEntityForm, so the instanceof check isn't needed and there's a
$this->showRevisionUi()method already that can be used.I guess my real question is: why do we need this when I don't see any other part of core doing it?
The only time I see
revision_log_messagerelated to form displays is for things like Term where it's being hidden. Which implies that the default is to have this shown. So is there some other place we're doing something wrong instead?In fact, there are only two places in core that
$form_display->setComponent()is ever called: a form alter (which makes sense), and here. That makes me feel like we're missing somethingprotected not public
I bet this is copied from somewhere else, so no one's fault here. But this should use the
OverridesSectionStorage::constant instead of 'layout_builder__layout'Comment #37
joegraduateAddressed items 1, 3 & 4 from #36.
@tim.plunkett Re: item 2 in #36, I definitely don't know the answer to your question(s) but the only alternative to this implementation that I can think of would be to change the
$default_fallbackparameter toTRUEin the call toEntityFormDisplay::collectRenderDisplay()and I imagine that would cause other problems.FWIW, it seems that this issue was introduced as a result of the changes committed for #3038442: Use hook_entity_form_display_alter() instead of Layout Builder's custom overrides display altering hook (based on earlier comments #4 and #7 in this issue).
Comment #38
mitthukumawat commentedPatch applied successfully for me on drupal 9.3.x-dev version. Thanks for the patch. RTBC +1
Comment #40
joegraduateCreated MR from #37 to make Tugboat QA site available.
Comment #41
joegraduateUpdated issue title and issue summary because this part of the original issue report is not reproducible in 9.3.x:
Comment #42
tim.plunkettI would still like to explore #36.2, might have to ping an Entity Field API expert.
Hiding the old patches now that we're using an MR.
Comment #45
dcam commentedMy content supervisors are asking for this functionality, so I tested the patch on our dev site. It worked. The revision message field is now visible and usable on the Layout Builder page. I'll see if I can find time to do a proper patch review later.
Comment #46
luke.leberI think that this can be safely moved to RTBC without addressing #36.2. The solution seems to work great and there is test coverage.
My rationality here is that imperfect under-the-hood implementation is preferable to broken functionality. In situations like this, IMO it is preferable to restore functionality and then open a task to address any concerns in the working functionality.
Comment #47
quietone commentedThe MR is on 9.3.x. Let's get a patch for 9.5 and 10.
Comment #48
ravi.shankar commentedAdded a patch for Drupal 9.5.x which is also getting applied on Drupal 10.1.x
Comment #50
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Moving to NW for an answer for 36.2
Comment #52
uniquename commentedThe patch from #48 seems to create a corrupted revision, when saving the layout form without any changes.
Steps to reproduce:
1. Get a fresh installed d10.1.5 with layout builder enabled and the patch applied.
2. Have a content type that has the full view enabled for layout builder.
3. Create a node of that content type.
4. This will create the first revision on /node/1/revisions.
5. Goto /node/1/layout and press save layout without changing anything.
6. No new revision will show up on /node/1/revisions.
7. Goto /node/1/layout, move a block an press save layout.
8. A new revision will show up on /node/1/revisions, but hast vid 3.
I've also found that in the DB in node_field_revision are three entries, so 5. created data, but this row has the revision_translation_affected field emtpy. That's why it's not showing up on /node/1/revisions.
Edit: Sorry, just realized that even without the patch, a corrupted revision get's saved. So is is probably another bug.
Comment #53
firewaller commentedPatch #48 resolves the issue for us
Comment #54
matthiasm11 commentedComment #55
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #58
bkosborneThis looks good to me. I merged in the latest from 11.x and fixed a couple minor deprecation issues in the test.
Comment #59
catchCommitted/pushed to 11.x and cherry-picked to 11.3.x, thanks!