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.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3147148-3.patch | 1.64 KB | DarKFlameS |
Issue fork drupal-3147148
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:
- 3147148-media-library-form-workspaces
changes, plain diff MR !11871
Comments
Comment #2
DarKFlameS commentedMakes media library form workspace safe
Comment #3
DarKFlameS commentedComment #4
DarKFlameS commentedFix wrong paths on previous patch
Comment #6
DarKFlameS commentedUpdated with a fix on media library widget views form
Comment #7
phenaproximaThis 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.
Comment #8
phenaproximaRaising the priority here because if this is breaking integration with Workspaces, that's a major thing we need to fix.
Comment #9
mandclu commentedUpdated the IS with additional detail including steps to reproduce, as I encountered this bug as well in Drupal 9.2.
Comment #10
mandclu commentedUsing 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).Comment #13
s_leu commentedAs 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.
Comment #16
adamzimmermann commentedAssumption: 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!
Comment #17
adamzimmermann commentedFor 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.
Comment #20
amateescu commented@adamzimmermann
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.
Comment #21
smustgrave commentedCan the IS be updated please.
Comment #22
himani_219 commentedComment #23
amateescu commentedUpdated the IS.
Comment #24
smustgrave commentedThanks 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
Comment #28
catchLooks good. Committed/pushed to 11.x, 11.1.x and 10.5.x, thanks!
Comment #31
pameeela commented