Problem/Motivation
When changes are made in a sub-workspace and pushed to the live workspace, the sub-workspace does not clear old changes as expected. This is due to the WorkspaceAssociation::onPostPublish() method not deleting the associations of sub-workspaces when published to the live workspace. The issue persists as old changes continue to appear after merging and publishing.
Steps to reproduce
1. Set up Drupal with the Workspaces module enabled.
2. Create a parent workspace and multiple sub-workspaces.
3. Make changes in a sub-workspace.
4. Merge the sub-workspace changes into the Stage workspace.
5. Publish changes from the Stage workspace to the Live workspace.
6. Verify that the sub-workspace has been cleared and old changes are no longer present.
Proposed resolution
To resolve this issue, we need to implement a cleanup logic to ensure that the associations between sub-workspaces and their changes are properly removed when changes are published to the live workspace. This will prevent old changes from persisting and ensure that the workspace accurately reflects the latest changes.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3438769-sub-workspace-not-clear-10.3.x.patch | 1.29 KB | antonnavi |
Issue fork drupal-3438769
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 #2
amateescu commentedThis will be fixed in #3323317: Revision metadata is not updated when a workspace is merged into its parent.
Comment #3
michelle@amateescu,
Thanks for finding that. I did search quite a bit before filing these issues but I guess I just wasn't using the right terms. I was calling it "sub workspace" not "develop workspace". If I hit any more problems, I'll search on that.
Comment #4
damienmckennaComment #5
amateescu commentedTurns out I was wrong in #2, the problem here is
WorkspaceAssociation::onPostPublish()not deleting the associations of sub-workpaces.Comment #6
damienmckennaComment #7
erik_mc commentedBumping for visibility.
Comment #8
amitvin commentedAs the workspace association is not getting deleted, One is not able to edit the content on the live workspace even if the content is published. Right now getting the message that content can not be edited as the content is edited in the sub workspace.
A temporary workaround is to delete the association manually (from the database) after merging the sub-workspace with the parent workspace.
Comment #9
antonnaviHello all here,
I had the same bug and fixed it in the way of adding additional cleanup on publication to Live workspace.
See details in attached patch file.
Comment #10
antonnaviComment #11
smustgrave commentedHello, all fixes should be in MRs against 11.x so tests will run.
Also issue summary should be complete and a clear title. Tagging for both.
With most bugs will also need a test case showing the issue
Comment #14
vinmayiswamy commentedComment #15
vinmayiswamy commentedHi, I have created an MR incorporating the patch changes from comment #9 and added a test case to validate these changes as outlined in comment #11. The issue summary has been updated accordingly.
I am removing the "Needs issue summary update" and "Needs tests" tags. If anyone believes these tags should still be applied, please feel free to re-add them.
Kindly review the changes and let me know if any further adjustments or updates are needed. Your feedback and suggestions for further improvements are greatly appreciated.
Thanks!
Comment #16
scott weston commentedReviewed code of #13 (and #9) and tested on Drupal 11.0.1 clean Standard installation with default and custom content types, taxonomy terms, and menu links. The bug experienced is no longer happening. Updating status to RTBC.
Comment #17
catchOne question on the MR.
Comment #18
vinmayiswamy commentedComment #19
smustgrave commentedFeedback appears to be addressed.
Comment #24
catchThanks that looks better.
Committed/pushed to 11.x and cherry-picked back through to 10.3.x, thanks!
Comment #26
antonnaviHello all,
The code:
which was committed to the core, there is a bug in this line:
The
$target_entity_idsvariable is an array where keys - revision IDs and values - entity IDs. So instead of:should be:
to get entity IDs instead of revisions.
Comment #31
catchThanks that's a good spot!
I've rolled this back from all four branches, let's re-add it with some additional test coverage.
Comment #33
vinmayiswamy commentedThank you, @antonnavi, for highlighting the incorrect usage of
$target_entity_ids_list = array_keys($target_entity_ids);.I’ve updated the code to use
$target_entity_ids_list = array_values($target_entity_ids);, which correctly retrieves the entity IDs instead of revision IDs. Additionally, I've added test coverage to verify this change, ensuring that workspace associations are properly cleaned up when publishing the workspace.Kindly review the changes and please let me know if any further adjustments are needed. Your feedback and suggestions for improvements are greatly appreciated.
Thanks!
Comment #34
catchIn this context is array_values actually useful? i.e. do we need to replace the revision ID keys with indexed keys or does it not matter?
Comment #35
smustgrave commented#34 seems worth exploring.
Comment #36
amateescu commentedReviewed the MR and fixed all my comments, sorry for taking so long to get to this folks.
Comment #37
smustgrave commentedFeedback appears to be addressed!
Comment #42
catchCommitted/pushed to 11.x and cherry-picked back through to 10.3.x, thanks!