Problem/Motivation
I use workspaces core module on my drupal 9 site. Also I've installed the redirect module to created redirects from old url alias to the new one in case if alias is changed.
Now I can not edit the node on non-live workspaces due to this error:
Drupal\Core\Entity\EntityStorageException: This entity can only be saved in the default workspace. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 811 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
After some investigation it turned out that issue is related to redirect entity. But actually this entity is revisionable, so it's fine to create redirects on any workspace.
Another example is related to the image field. I use crop module for image cropping and added the image field to the page node type as usual to make it possible to use media image library to insert some image to the node.
Now I'm getting the same error (This entity can only be saved/deleted in the default workspace) when I try to add an image to the node on non-live workspace. First it was related to crop entity, then it was related to the file entity (after I've disabled cropping).
But again it's totally fine to create entities of these types on non-live workspaces. Also how can I edit nodes if I can't upload/use images on non-live workspaces?
Steps to reproduce
- Install and enable the following modules: crop, redirect.
- Add the media/image field to some node type.
- Create some node.
- Switch to Stage (or any other) workspace.
- Try to add/change the image of that node.
- Or try to change path alias of that node.
The 'This entity can only be saved/deleted in the default workspace' fatal error would be displayed.
Proposed resolution
Make it possible to configure entities that could be skipped by workspaces module.
For example, I've tried to refactor the Drupal\workspaces\EntityOperations::shouldSkipPreOperations() to return TRUE to respective entity types and then everything works fine.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | interdiff_5-6.txt | 1012 bytes | pooja saraah |
| #6 | 3317942-6.patch | 2.61 KB | pooja saraah |
| #5 | 3317942-5.patch | 2.77 KB | immaculatexavier |
Comments
Comment #2
i-grou commentedComment #3
i-grou commentedComment #4
i-grou commentedComment #5
immaculatexavier commentedAttached patch in-accordance to the proposed resolution.
Comment #6
pooja saraah commentedFixed failed commands on #5
Attached interdiff patch
Comment #7
i-grou commented@immaculatexavier, @poojasaraah sorry I don't understand how this patch would fix the issue.
First, condition is always FALSE, hence it would never return on that step.
Second, there is no check neither for entity type nor for entity property (like revisionable). Does it make sense to try to create an exception that affect all entity types?
Third, does this approach really makes things configurable? How can I make it work for entities like redirect and not to work for some other entity?
Comment #8
amateescu commentedThis will be fixed by #3101671: Add mechanism to have workspaces skip processing entity types, which will allow marking entity types as "ignored" in a workspace.