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

Command icon 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

krisahil created an issue. See original summary.

krisahil’s picture

Status: Active » Needs work

amateescu made their first commit to this issue’s fork.

  • amateescu committed d112a44a on 3.0.x authored by krisahil
    fix: #3571367 Preview cookie gets dropped if entity workspace status...
amateescu’s picture

Status: Needs work » Fixed

So.. the proper fix would be to enhance core's WorkspaceSwitchEvent with a "is temporary" flag, but the practical solution is to handle it inside WSE for now :)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

amateescu’s picture

Project: Workspaces Extra » Workspace Preview
Version: 3.0.x-dev » 1.0.x-dev
Component: Workspace Preview » Code

WSE Preview has been promoted to a standalone module: https://www.drupal.org/project/workspace_preview