On preexisting site, enabling workspaces leads to

Created on 3 December 2024, 19 days ago

Problem/Motivation

On a preexisting site, I enabled Workspaces and wanted to see if I could easily edit content while in a Workspace. I immediately ran into white-screen-of-death errors upon saving. The error I received was:

"This content can only be saved in the default workspace"

I did some debugging and was able to see that it was specifically the menu_link_content entity type that was having trouble. I also noticed the WorkspaceInformation compiled a list of entity types that it determined had proper workspace support. That code evaluated menu_link_content along with 9 other entity types computed the support level for each.

There are way more than 9 entity types in Drupal.

I then discovered that after flushing the plugin cache with drush cc > choose plugin I could edit content and debugging showed that 74 entity types were in the supported list. menu_link_content's support level flipped from false to true

I'm not exactly sure what all of this means, except that perhaps it would be good to include a plugin cache flush when workspaces is enabled.

Steps to reproduce

1. With Drupal 10.3.9, enable workspaces on a preexisting site.
2. Switch to Stage workspace.
3. Modify and save existing content. Ideally the content should define it's own menu link or have paragraphs.
4. Observe a white screen of death error that reads "This content can only be saved in the default workspace."

Proposed resolution

Flush plugin cache

Then repeat the steps:
1. Edit the same content, the same way.
2. Success

Remaining tasks

Validate that this error occurs for more people other than just me.
Determine if flushing the plugin cache is a viable solution.

Release notes snippet

Improve workspaces for preexisting sites.

πŸ› Bug report
Status

Active

Version

10.3 ✨

Component

workspaces.module

Created by

πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

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

Merge Requests

Comments & Activities

  • Issue created by @cosmicdreams
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    Update here, I'm finding the that clearing of the plugin cache is not a permanent solution. The issue recurs when you make another edit.

    I'm starting to thing that the proper path to a solution here is to extend the menu_link_content entity to explicity declare that it has workspace support instead of indirectly compute it's workspace support as a result of the revision support that it has.

    adding a line to the entity metadata makes this clear:

    handlers = {
     *     "storage" = "\Drupal\menu_link_content\MenuLinkContentStorage",
     *     "storage_schema" = "Drupal\menu_link_content\MenuLinkContentStorageSchema",
     *     "access" = "Drupal\menu_link_content\MenuLinkContentAccessControlHandler",
     *     "form" = {
     *       "default" = "Drupal\menu_link_content\Form\MenuLinkContentForm",
     *       "delete" = "Drupal\menu_link_content\Form\MenuLinkContentDeleteForm"
     *     },
     *     "list_builder" = "Drupal\menu_link_content\MenuLinkListBuilder",
     *     "workspace" = "Drupal\workspaces\Entity\Handler\DefaultWorkspaceHandler"
     *   },
    
  • πŸ‡·πŸ‡΄Romania amateescu

    Found the problem, when we introduced workspace handlers in πŸ“Œ Add mechanism to have workspaces skip processing entity types Fixed we forgot that we should also set them on the last installed entity type definitions.

  • Merge request !10510Fix workspace handlers. β†’ (Open) created by amateescu
  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    I'll be able to test this patch tonight.

  • πŸ‡·πŸ‡΄Romania amateescu

    I think this needs an upgrade path as well, so the only useful testing atm is on a site where Workspaces hasn't been installed yet. Or at least uninstalled and then installed again :)

  • Pipeline finished with Failed
    11 days ago
    Total: 10287s
    #364814
  • Pipeline finished with Failed
    10 days ago
    Total: 586s
    #366494
  • Pipeline finished with Failed
    9 days ago
    Total: 5817s
    #367013
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks for always including test coverage, makes issues go by so much easier!

    I re-ran the failures

    Time: 00:12.169, Memory: 10.00 MB
        
        Workspace Handler Update Path (Drupal\Tests\workspaces\Functional\Update\WorkspaceHandlerUpdatePath)
         ✘ Run updates
           ┐
           β”œ Failed asserting that null is identical to 'Drupal\workspaces\Entity\Handler\IgnoredWorkspaceHandler'.
           β”‚
           β”‚ /builds/issue/drupal-3491193/core/modules/workspaces/tests/src/Functional/Update/WorkspaceHandlerUpdatePathTest.php:55
           β”΄
    

    This keeps failing though.

  • Pipeline finished with Canceled
    7 days ago
    Total: 524s
    #368644
  • πŸ‡·πŸ‡΄Romania amateescu

    That's a great failure, it shows that we're testing things properly. Fixed the update function.

  • Pipeline finished with Success
    7 days ago
    Total: 4467s
    #368651
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks for the quick turnaround, changes look good to me.

  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    Should this issue also be concerned with the MenuLinkContent entity. In general, do we introduce harm to the platform by declaring support for workspace within the Entity definition vs having the system determine an entity's support for workspaces through it's current logic?

  • πŸ‡·πŸ‡΄Romania amateescu

    @cosmicdreams, the MR is handling all workspace-supported entity types. But it would be great if you could test it on your site for an additional confirmation.

  • πŸ‡ΊπŸ‡ΈUnited States cosmicdreams Minneapolis/St. Paul

    cool. That's on deck for today.

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    I have a couple of concerns about the approach. We're moving code into the block_content module that depends on workspaces even though block_content does not depend on workspaces - are we sure this is the correct thing to do?

  • πŸ‡·πŸ‡΄Romania amateescu

    This is no different than entity types specifying \Drupal\views\EntityViewsData as their views_data handler, or even having entity type specific handlers (NodeViewsData extends EntityViewsData), without depending on Views :)

Production build 0.71.5 2024