Problem/Motivation
While working on sub-issues of #3575638: [META] Workspaces support for config entity types, I bumped into various deficiencies and bugs in our workspace-aware config storage implementation. Fixing them individually would've been quite hard (read: time consuming), so I'm using this issue to handle them all.
Proposed resolution
Rewrite config publishing — Extract publishing logic from WseConfigSubscriber into a dedicated WseConfigPublishingSubscriber. Instead of calling publishWseConfig() which used to write directly to inner storage, collect workspace config data via getWorkspaceConfigData(), build a MemoryStorage representing the desired end state (Live baseline + workspace overlay), and use StorageComparer + ConfigImporter to apply changes. This gives proper dependency ordering, lifecycle hooks, and entity CRUD — matching how drush config:import works.
Support config deletion in workspaces — Distinguish between workspace-only config (actually delete the entity) and Live config (create a delete marker with data = NULL). Delete markers flow through read(), exists(), readMultiple(), and listAll() so deleted config appears absent in the workspace. On publish, delete markers cause ConfigImporter to remove the config from Live. Simplify the access check in entityAccess() to use enabled_config_entity_types setting instead of querying for existing wse_config entities, which previously blocked deletion of Live-only config.
Support config rename in workspaces — Handle Live-only config in rename() by reading from inner storage, writing under the new name, and creating a delete marker for the old name. Clean up any existing entity for the target name.
Optimize read path — Add getOverriddenNames() using an aggregate entity query to cache the set of config names with workspace overrides. Skip entity lookups in exists(), read(), and readMultiple() for configs with no workspace override, avoiding per-read database queries for the vast majority of config reads.
Add test coverage — Add comprehensive WseConfigStorageTest covering read, write, exists, readMultiple, listAll, delete, rename, deleteAll, getAllCollectionNames, and workspace switch isolation. Extend WseConfigBundleEntityTest to cover deletion of both workspace-created and Live config entities through publish.
Data model changes
Simplified the WseConfig entity type — Remove translatable support and unnecessary fields (langcode, data/revision data tables, uid customization). Make name and collection fields ASCII-only. Allow data to be nullable to support delete markers. Added an update hook to migrate the db schema.
Issue fork wse-3576850
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 #4
amateescu commentedMerged!