Problem/Motivation
Workspace config (wse_config) enables us to change config entities inside a workspace and to deploy them. However in order to actually enable this for any entity type, we still need to write code inside hook_entity_type_alter() to mark config entity types as internal and thus make CRUD operations for a type work inside a workspace.
If we don't do so, core's EntityOperations::shouldSkipPreOperations prevents us from using any config entity type that isn't marked as "internal".
Steps to reproduce
On Vanilla Drupal 9
- Enable wse_config
- Switch to the stage workspace
- Navigate to /admin/structure/block and try adding a block
- Workspaces will block this with an exception "This entity can only be saved in the default workspace."
Proposed resolution
Expose the relevant (some need to be excluded) config entity types on the settings form in a multi select. Then implement hook_entity_type_alter() to mark the types selected on the settings form as internal.
Issue fork wse-3293758
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 #3
s_leu commentedComment #4
amateescu commentedComment #6
amateescu commentedMerged into 1.0.x, thanks!
Comment #8
s_leu commentedThere's one small issue here: Once the settings are saved, the changes aren't in effect yet as entity definitions are cached in the discovery cache bin, thus we need to clear that cache when this setting is changed in order to get the changes to work right after submitting the settings form.
Comment #10
amateescu commentedMerged the followup :)
Comment #12
amateescu commentedComment #13
mvnovick commentedThere is still a problem with the linkcheckerlink config entity type which is used by the Link Checker module. When a workspace is active, and a node with a link in an HTML text field is being saved, the following error occurs:
Drupal\Core\Entity\EntityStorageException: The "linkcheckerlink" entity type can only be saved in the default workspace. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 817 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).The linkcheckerlink config entity type needs to be added to the list of option is the Enabled config entity types multi-select field in the Workspace Settings page. I was able to get around this error by marking linkcheckerlink config entity type as "internal" inside hook_entity_type_build():