Deleting latest revision deletes all entries in workspace_association table

Created on 19 March 2025, 19 days ago

Problem/Motivation

Deleting a revision in a workspace removes the workspace association for that entity. This means the revision is no longer shown in an active workspace and the live one is used instead.

Steps to reproduce

1. Install drupal + workspaces
2. Create a page
3. Switch to stage workspace
4. Edit and save the page in the workspace
5. Do #3 again, make sure to change something
6. Switch to live
7. Go to Revisions on the page
8. Verify 3 revisions (the live one, plus 2 revisions from the workspace)
8. Delete the latest revision
9. Go to Workspaces and select Stage
10. Page is no longer in the workspace.

Additionally the workspace_association table is empty. The 2nd to last revision should have been used.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component

workspaces.module

Created by

πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @djdevin
  • πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia
  • πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia
  • πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia
  • πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia
  • πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia

    Added a test that illustrates the problem.

  • πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia

    Thinking about how we could solve this.

    I thought it would be possible to just associate both revisions with the workspace, so if one revision is disassociated the other one will still be there.

    But, there's a unique index on the workspace_association table that prevents this:

    PRIMARY KEY (`workspace`,`target_entity_type_id`,`target_entity_id`,`target_entity_id_string`)

    It's strange that only one record per entity can exist here, but in a table like node_revision, multiple revisions can be associated with a workspace. Maybe we should update the index (and the code) to work off of the revision instead.

    Another option is to update deleteAssociations() to either delete associations or update them to the most recent workspaced revision. But, that's probably confusing without renaming deleteAssociations to updateOrDeleteAssociations...

  • πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia
Production build 0.71.5 2024