Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
This came up as a review point in #2784921-110: Add Workspaces experimental module.16:
+++ b/core/modules/workspace/src/Plugin/RepositoryHandler/LocalWorkspaceRepositoryHandler.php @@ -0,0 +1,269 @@ + + // Only switch to the target workspace and save entities if there are some + // to save. + if (!empty($entities)) { + // Before saving set the active workspace to the target. + $this->workspaceManager->setActiveWorkspace($target_workspace); + // Save each revision on the target workspace. + foreach ($entities as $entity) { + $entity->save(); + } + }
This should happen in a transaction so we can roll back if any of the entity saves fail. Additionally there currently appears to be no protection for saving items in a workspace over more recently updated entities on live - that could happen either via a pre-deploy audit or when saving but seems like we need one or the other?
Note that the second part of the comment was already fixed in #2938626: Do not allow concurrent edits in different workspaces.
Proposed resolution
Do it.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#2 | 2940241.patch | 4.06 KB | amateescu |
|
Comments
Comment #2
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNothing that could fail here I think.
Comment #3
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedSlightly better title.
Comment #5
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedAnd committed!