Problem/Motivation
Environment:
Drupal 8.6
Workspaces in core 8.6
Layout Builder in core 8.6
Process:
1. Fresh install of Drupal 8.6
2. Workspaces is enabled with two work spaces Live and Stage as generated out of the box when workspaces was enabled
3. Layout builder and Layout Discovery are also enabled
4. Create content type with layout enabled, and specific enable "Allow each content item to have its layout customized."
5. Create a piece of content using new content type in LIVE workspace, override layout and add blocks, works fine.
6. Change into STAGE workspace, try to override layout on same content item and layout UI will not allow to add blocks or remove components.
Proposed resolution
1. Should be able to override a layout for an individual content item in STAGE workspace.
2. Changes to layout in STAGE should not be visible on LIVE environment
3. Ability to then push those layout changes and any content revisions from STAGE to LIVE.
Remaining tasks
Review.
User interface changes
Nope.
API changes
Nope.
Data model changes
The inline_block
block plugin now also stores the block's ID in addition to its revision ID.
Comment | File | Size | Author |
---|
Issue fork drupal-3000749
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
velocis CreditAttribution: velocis commentedComment #3
tim.plunkettWorkspace prevents all* forms from submitting when not in the default workspace.
* (except some entity forms, the search forms, views exposed forms, and its own forms)
This was confusing at first, due to our bug #2968110: Layout Builder's ConfigureBlockFormBase forms do not display validation errors on submit
Someone, I think @tedbow, mentioned off-hand that there would be a benefit to reimplementing Layout Builder's UI as a series of entity forms. Possibly for this reason?
In the meantime, here's a "quickfix" that is probably horribly incorrect.
Comment #5
tim.plunkettComment #7
smithmilner CreditAttribution: smithmilner at Myplanet commentedRerolling against 8.9.x
Comment #8
tim.plunkettMoving this to workspaces.
Comment #9
Neslee Canil PintoComment #10
tim.plunkett#9 is the exact same patch as #7? Byte for byte...
Anyway, this is still the quickfix I posted 18 months ago. Will likely need a new approach completely.
Comment #13
adamzimmermann CreditAttribution: adamzimmermann at Chromatic commentedThis patch seems to work except for with custom blocks defined from
/admin/structure/block/block-content/types
.When adding a custom block, I see the following in the logs after trying to save and getting a white screen.
I'm not familiar with any of the layout builder codebase, but if this sparks an idea for someone, I would be happy to help work on a patch.
Comment #14
jeremylichtman CreditAttribution: jeremylichtman at Lichtman Consulting commented@adamzimmermann, attaching a patch that prevents layout builder from crashing due to empty block_content_id.
The behaviour is a bit odd with the patch though: when you first save the page with the new block in "staging" mode, the block will be marked as unpublished. Editing and setting it to published works, however, and this is better than a crash.
Comment #15
amateescu CreditAttribution: amateescu for Tag1 Consulting commentedThis patch enables Layout Builder to work together with Workspaces. It depends on #3208390: Add an API for allowing modules to mark their forms as workspace-safe and it also fixes the problem reported in #13.
Leaving at NW because it needs some test coverage too.
Comment #16
amateescu CreditAttribution: amateescu for Tag1 Consulting commentedHere's a version of the patch from #15 for 8.9.x, for anyone who needs it.
Comment #17
mpotter CreditAttribution: mpotter at Phase2 commented+1. The patch in #15 also works well for another use case:
When using Domain Access and enabling access control for Custom Block entities, adding a custom block to Layout Builder and selecting a domain to restrict access causes the same "Column 'block_content_id' cannot be null" error. This patch fixes this and allows the layout to be saved.
If the block_content_id fix is something more general than the OP specific fix for Workspace, maybe it needs to be split out as a separate bug fix issue to get moved forward more easily?
Comment #22
s_leu CreditAttribution: s_leu at Tag1 Consulting commentedAdding some tests for this. I had to make a change in
EntityReferenceItem::generateSampleValue()
to make the tests with workspaces work and this change could also be related to #3000950: Sample images cannot be generated while in a non-default workspace.Comment #23
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #24
pooja saraah CreditAttribution: pooja saraah at Material for Drupal India Association commentedFixed failed commands on #22
Attached patch against Drupal 10.1.x
Attached interdiff
Comment #25
kazajhodo CreditAttribution: kazajhodo at August Ash commentedI'm not sure if I'm doing this right, but I found that layout builder would crash and throw duplicate primary key errors on entity clone. This would also create orphaned inline_block_usage rows, with empty layout_entity_id.
The cloned entity would also no longer save, due to the orphaned references.
I added a check in InlineBlockEntityOperations->saveInlineBlockComponent(), for entity id. Line 233.
The entity is always set, but in some cases the entity id would be empty, causing addUsage() to fail. This seems to work fine and nodes save layout builder properly.
This is against 9.5, however I think its relevant to this issue? Its exactly the same as the 10.1 patch, with an addition if statement- so should be fine for 10.1 as well. If the check is in the proper spot, thats an entirely different question. At my experience level... I believe so, but not positive.
I went through entity_clone, thinking the actual issue was there; but was unable to find the potential root culprit.
Comment #26
pooja saraah CreditAttribution: pooja saraah at Material for Drupal India Association commentedFixed failed commands on #25
Attached patch against Drupal 10.1.x
Comment #27
Prem Suthar CreditAttribution: Prem Suthar at Material for Drupal India Association commentedTry To Fix The #26 Custom Commands Failed Patch.
Comment #28
Prem Suthar CreditAttribution: Prem Suthar at Material for Drupal India Association commentedTry To Fix The #27 CMF.
Comment #30
dragos-dumi CreditAttribution: dragos-dumi commentedUpdated #28 with the event from https://www.drupal.org/project/drupal/issues/3208390#comment-15200955
Comment #32
amateescu CreditAttribution: amateescu for Tag1 Consulting commentedConverted the latest patch to a MR, changed the approach for marking LB forms as workspace-safe by using a trait and marking individual forms, so this issue doesn't depend on #3208390: Add an API for allowing modules to mark their forms as workspace-safe anymore.
Tests were added in #22, I just moved them to the Workspaces module, so removing the tag.
Comment #33
amateescu CreditAttribution: amateescu for Tag1 Consulting commentedComment #34
smustgrave CreditAttribution: smustgrave at Mobomo commentedStill probably needs @tim.plunkett sign off, but with the schema change I imagine we would need an upgrade path right?
Comment #35
amateescu CreditAttribution: amateescu for Tag1 Consulting commentedReplied in the MR why I don't think an upgrade path is needed.
Comment #36
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedRTBC - looks great to me and makes sense!
Comment #37
catchWould like to commit this one, but I don't understand the answer about the upgrade path entirely, so asked on the MR. Back to needs review again for that. I agree we don't need a content upgrade path, but would like to know why we don't need a config upgrade path to match the new schema.
Comment #38
amateescu CreditAttribution: amateescu for Tag1 Consulting commentedReplied in the MR :)
Comment #41
catchOK that's a very confusing situation, but it's not a situation that was introduced here, and the explanation is spot on, so... Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks! Really nice to get this one in!