From d7c8f29104d2e03db64f790fe18ef520f055c513 Mon Sep 17 00:00:00 2001
From: Alexander Opitz <opitz.alexander@googlemail.com>
Date: Fri, 12 Jan 2018 17:08:07 +0100
Subject: [PATCH] [BUGFIX] Allow workspace preview inside another rootline

The rootline for page view now depends on the webmounts of the workspace
the preview link was generated on and not the webmounts the beuser, who
generated the preview link, is at the moment of calling the preview
link.

Resolves: #83547
Releases: master, 8.7
Change-Id: I53c8d45260b79c4d5679f00084fe81b502668ee7
Reviewed-on: https://review.typo3.org/55341
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
---
 typo3/sysext/workspaces/Classes/Hook/PreviewHook.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/workspaces/Classes/Hook/PreviewHook.php b/typo3/sysext/workspaces/Classes/Hook/PreviewHook.php
index d367037ae78e..a63c4753aeb4 100644
--- a/typo3/sysext/workspaces/Classes/Hook/PreviewHook.php
+++ b/typo3/sysext/workspaces/Classes/Hook/PreviewHook.php
@@ -114,6 +114,8 @@ class PreviewHook implements \TYPO3\CMS\Core\SingletonInterface
             $tempBackendUser->setBeUserByUid($this->previewConfiguration['BEUSER_uid']);
             if ($tempBackendUser->user['uid']) {
                 $tempBackendUser->unpack_uc();
+                $tempBackendUser->setTemporaryWorkspace($workspaceUid);
+                $tempBackendUser->user['workspace_id'] = $workspaceUid;
                 $tempBackendUser->fetchGroupData();
                 // Handle degradation of admin users
                 if ($tempBackendUser->isAdmin()) {
@@ -137,7 +139,7 @@ class PreviewHook implements \TYPO3\CMS\Core\SingletonInterface
                         ->execute()
                         ->fetch();
 
-                    // Either use configured workspace mount or current page id, if admin user does not have any page mounts
+                    // Either use configured workspace mount (of the workspace) or current page id
                     if (empty($tempBackendUser->groupData['webmounts'])) {
                         $tempBackendUser->groupData['webmounts'] = !empty($workspaceRecord['db_mountpoints']) ? $workspaceRecord['db_mountpoints'] : $pObj->id;
                     }
-- 
GitLab