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.

Issue fork drupal-3000749

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

velocis created an issue. See original summary.

velocis’s picture

tim.plunkett’s picture

Workspace 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.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tim.plunkett’s picture

Status: Active » Needs work

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

smithmilner’s picture

FileSize
3.65 KB

Rerolling against 8.9.x

tim.plunkett’s picture

Component: layout_builder.module » workspaces.module

Moving this to workspaces.

Neslee Canil Pinto’s picture

Status: Needs work » Needs review
FileSize
3.65 KB
tim.plunkett’s picture

#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.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

adamzimmermann’s picture

Status: Needs review » Needs work

This 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.

1606513   10/Nov 19:55   php                Error      Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'block_content_id' cannot be null: INSERT INTO {inline_block_usage} (block_content_i
  1606512   10/Nov 19:55   node               Error      Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'block_content_id' cannot

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.

jeremylichtman’s picture

FileSize
795 bytes

@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.

amateescu’s picture

Issue tags: -Workspaces core +Needs tests
FileSize
7.25 KB

This 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.

amateescu’s picture

FileSize
7.29 KB

Here's a version of the patch from #15 for 8.9.x, for anyone who needs it.

mpotter’s picture

+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?

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

s_leu’s picture

Status: Needs work » Needs review
FileSize
16.16 KB
8.92 KB

Adding 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.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
4.57 KB

The 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.

pooja saraah’s picture

Fixed failed commands on #22
Attached patch against Drupal 10.1.x
Attached interdiff

kazajhodo’s picture

I'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.

pooja saraah’s picture

Fixed failed commands on #25
Attached patch against Drupal 10.1.x

Prem Suthar’s picture

Try To Fix The #26 Custom Commands Failed Patch.

Prem Suthar’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dragos-dumi’s picture

amateescu’s picture

Title: Layout builder overrides on a single content item not allowed in stage when using workspaces » Layout builder overrides on a single content item not allowed in a workspace
Category: Feature request » Bug report
Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests

Converted 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.

smustgrave’s picture

Still probably needs @tim.plunkett sign off, but with the schema change I imagine we would need an upgrade path right?

amateescu’s picture

Issue tags: +WI critical

Replied in the MR why I don't think an upgrade path is needed.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

RTBC - looks great to me and makes sense!

catch’s picture

Status: Reviewed & tested by the community » Needs review

Would 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.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Replied in the MR :)

  • catch committed 71a1ab74 on 10.3.x
    Issue #3000749 by amateescu, s_leu, dragos-dumi, tim.plunkett,...

  • catch committed bf22a795 on 11.x
    Issue #3000749 by amateescu, s_leu, dragos-dumi, tim.plunkett,...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

OK 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.