Problem/Motivation

Currently, while in a workspace, it is not possible to create new media entities. This significantly hampers the usefulness and editorial experience of using Workspaces, especially when managing media-rich content.

Steps to reproduce

  • Using a fresh Drupal 11.x Umami install, enable the Workspaces module and create a workspace.
  • Switch to the new workspace.
  • Create or edit a recipe. For the main image field, open the media library and attempt to upload an image to create a new entity.
  • Alternatively, try to create a new image media directly in the media library.

Either way, you will encounter the error: "This form can only be submitted in the default workspace", and the media entity is not created.

Proposed resolution

Mark media library forms as workspace-safe.

User interface changes

Nope.

Introduced terminology

Nope.

API changes

Nope.

Data model changes

Nope.

Release notes snippet

Nope.

Issue fork drupal-3147148

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:

Comments

DarKFlameS created an issue. See original summary.

DarKFlameS’s picture

StatusFileSize
new779 bytes

Makes media library form workspace safe

DarKFlameS’s picture

Title: This form can only be submitted in the default workspace » Media library form can only be submitted in the default workspace
DarKFlameS’s picture

StatusFileSize
new799 bytes

Fix wrong paths on previous patch

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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.

DarKFlameS’s picture

StatusFileSize
new1.64 KB

Updated with a fix on media library widget views form

phenaproxima’s picture

Status: Active » Needs work
Issue tags: +Needs steps to reproduce, +Needs tests

This issue is filed as a bug report, but there are no steps to reproduce, nor any indication of how the bug manifests itself. This will also certainly need automated test coverage before it can be committed.

phenaproxima’s picture

Raising the priority here because if this is breaking integration with Workspaces, that's a major thing we need to fix.

mandclu’s picture

Version: 8.9.x-dev » 9.2.x-dev
Issue summary: View changes

Updated the IS with additional detail including steps to reproduce, as I encountered this bug as well in Drupal 9.2.

mandclu’s picture

Using the provided patch in Drupal 9.2 I don't see the error displayed anymore, but uploading an image in the form to create an image media entity in either scenario fails to upload, with no visible change to the form. Two errors are logged to watchdog:

Drupal\Core\Entity\EntityStorageException: This entity can only be saved in the default workspace. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 810 of /app/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

RuntimeException: This entity can only be saved in the default workspace. in Drupal\workspaces\EntityOperations->entityPresave() (line 124 of /app/web/core/modules/workspaces/src/EntityOperations.php).

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

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should 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.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

s_leu’s picture

As found in the previous comment, the latest patch here doesn't completely solve the problem outlined in the steps to reproduce as of issue summary, because it just marks the corresponding media forms as workspace safe, but image entities are still not supported in workspaces as they are not revisionable and publishable (see WorkspaceManager::isEntityTypeSupported() )

The issue with image entites in workspaces was filed and explained in more detail over at #3025785: Cannot create entity with image in a workspace, adding this as a related issue here.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

Version: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

adamzimmermann’s picture

Assumption: Most Drupal sites are uploading files using media entities, and media entities throw the error noted above when trying to edit them in the non-default workspace. This makes the workspaces module unusable (with media entities) as someone trying to implement it on a new site build right now.

I don't see any recent activity on this issue and the last patch seems to have issues from what others are reporting.

Is the workspaces module simply not being used on production sites yet, or how are others getting around this?

Do we need to alter media entities like they have done for files in #3025785: Cannot create entity with image in a workspace? Are there known side-effects to this that make this not a viable solution?

Any insight is much appreciated!

adamzimmermann’s picture

For anyone else having this issue, the Workspaces Extra module seems to help solve this and many other issues. It feels weird to need a contrib module for core functionality to work though.

amateescu made their first commit to this issue’s fork.

amateescu’s picture

Category: Feature request » Bug report
Priority: Major » Normal
Status: Needs work » Needs review
Issue tags: -Needs steps to reproduce, -Needs tests, -Needs issue summary update

@adamzimmermann

It feels weird to need a contrib module for core functionality to work though.

That's because core moves at a slower pace, and production sites needed a lot of various fixes for Workspaces that were lingering for years in the core queue for various reasons. Workspaces Extra had to incorporate all these little fixes to prevent developers from using a huge list of patches into their projects.

Opened a MR with a fix and test coverage for this issue.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Can the IS be updated please.

himani_219’s picture

Issue summary: View changes
amateescu’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Updated the IS.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks summary reads well

I was able to replicate following the steps and the MR does appear to address the problem
Test coverage seems to be there too.

LGTM

  • catch committed 14657877 on 10.5.x
    Issue #3147148 by DarKFlameS, amateescu, mandclu, smustgrave: Media...

  • catch committed a815f530 on 11.1.x
    Issue #3147148 by DarKFlameS, amateescu, mandclu, smustgrave: Media...

  • catch committed 8a10f82f on 11.x
    Issue #3147148 by DarKFlameS, amateescu, mandclu, smustgrave: Media...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks good. Committed/pushed to 11.x, 11.1.x and 10.5.x, thanks!

Status: Fixed » Closed (fixed)

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