Skip to content

Commit c1cf194

Browse files
[BUGFIX] Properly initialize backend user for requests
Default requests won't have a workspace id. That will lead to TYPO3 defaults -99 id. That in turn will lead to being in preview mode once a backend user is provided within context. We therefore cover the default and turn it into live workspace which could be the expected default. Also we add missing initialization for backend user. Resolves: #535
1 parent ee62a11 commit c1cf194

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Resources/Core/Functional/Extensions/json_response/Classes/Middleware/BackendUserHandler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
4040
/** @var InternalRequestContext $internalRequestContext */
4141
$internalRequestContext = $request->getAttribute('typo3.testing.context');
4242
$backendUserId = $internalRequestContext->getBackendUserId();
43-
$workspaceId = $internalRequestContext->getWorkspaceId();
43+
$workspaceId = $internalRequestContext->getWorkspaceId() ?? 0;
4444

4545
if ((int)$backendUserId === 0) {
4646
// Skip if $backendUserId is invalid, typically null or 0
@@ -55,10 +55,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
5555
// Init backend user if found in database
5656
$backendUser = GeneralUtility::makeInstance(FrontendBackendUserAuthentication::class);
5757
$backendUser->user = $row;
58-
if ($workspaceId !== null) {
59-
// Force backend user into given workspace, can be 0, too.
60-
$backendUser->setTemporaryWorkspace($workspaceId);
61-
}
58+
$backendUser->uc = isset($row['uc']) ? unserialize($row['uc']) : [];
59+
$backendUser->initializeUserSessionManager();
60+
$backendUser->fetchGroupData();
61+
$backendUser->setTemporaryWorkspace($workspaceId);
6262
$GLOBALS['BE_USER'] = $backendUser;
6363
$this->setBackendUserAspect(GeneralUtility::makeInstance(Context::class), $backendUser);
6464
}

0 commit comments

Comments
 (0)