Skip to content

Commit

Permalink
[BUGFIX] Properly initialize backend user for requests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DanielSiepmann committed Feb 21, 2024
1 parent ee62a11 commit c1cf194
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
/** @var InternalRequestContext $internalRequestContext */
$internalRequestContext = $request->getAttribute('typo3.testing.context');
$backendUserId = $internalRequestContext->getBackendUserId();
$workspaceId = $internalRequestContext->getWorkspaceId();
$workspaceId = $internalRequestContext->getWorkspaceId() ?? 0;

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

0 comments on commit c1cf194

Please sign in to comment.