Problem/Motivation
Under certain conditions, we have seen that the wse_preview cookie gets dropped from a user's browser session. This seems to happy when a user views an entity with the "entity_workspace_status" extra field on the page.
Steps to reproduce
I'll open an MR with a failing test, to illustrate the problem. In the meantime, here are steps to manually reproduce:
- Install site with Standard profile.
- Enable modules: workspaces workspaces_ui wse_preview
- Grant permission "Access workspace previews" to anonymous role.
- On the workspace settings page (/admin/config/workflow/workspaces/settings), enable the "Content" option under "Workspace status field".
- Flush caches.
- Set the "Workspace Status" field to display for basic page nodes (at
/admin/structure/types/manage/page/display).
- Create a Basic page node (this should be accessible at /node/1).
- Create a workspace and switch to it.
- Edit the node while in the new workspace.
- Generate a preview link for this workspace. Set "Redirect URL" to empty, so
that it redirects to the homepage.
- In a new browser session (e.g., Chrome incognito), go to this preview link. You should be redirected to the homepage.
- Verify that your session has cookie "wse_preview".
- Visit /node/1
- Notice that cookie "wse_preview" has been deleted. (This is the bug.)
- Reload page /node/1.
- Notice that you are no longer previewing the workspace. Instead, you are in the live workspace.
Proposed resolution
I don't know how to fix this. The problem stems from wse_entity_view call to \Drupal\workspaces\WorkspaceManager::executeOutsideWorkspace. This call triggers an event response that opens a Drupal session that eventually clears the wse_preview cookie (see \Drupal\wse_preview\Negotiator\CookieWorkspaceNegotiator::unsetActiveWorkspace).
Remaining tasks
?
User interface changes
?
API changes
?
Data model changes
?
Issue fork wse-3571367
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 #3
krisahil commentedComment #6
amateescu commentedSo.. the proper fix would be to enhance core's
WorkspaceSwitchEventwith a "is temporary" flag, but the practical solution is to handle it inside WSE for now :)Comment #9
amateescu commentedWSE Preview has been promoted to a standalone module: https://www.drupal.org/project/workspace_preview