From d0362c7bcd419b56aee7d53a38fb9b3bd82dcc8d Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Mon, 15 Nov 2021 12:02:09 +0100 Subject: [PATCH] [BUGFIX] Fix PHP 8.0 warnings in Workspace preview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: #95973 Releases: master Change-Id: I6f0358cfdc38aff55ce8e0ef4343cd50104d93c3 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72171 Tested-by: core-ci <typo3@b13.com> Tested-by: Achim Fritz <af@achimfritz.de> Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Achim Fritz <af@achimfritz.de> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Classes/Middleware/WorkspacePreview.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php b/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php index 7538b996a4b9..5e4e37c049cb 100644 --- a/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php +++ b/typo3/sysext/workspaces/Classes/Middleware/WorkspacePreview.php @@ -112,9 +112,9 @@ class WorkspacePreview implements MiddlewareInterface } // If keyword is set to "LIVE", then ensure that there is no workspace preview, but keep the BE User logged in. - // This option is solely used to ensure that a be user can preview the live version of a page in the + // This option is solely used to ensure that a be-user can preview the live version of a page in the // workspace preview module. - if ($keyword === 'LIVE' && $GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) { + if ($keyword === 'LIVE' && isset($GLOBALS['BE_USER']) && $GLOBALS['BE_USER'] instanceof FrontendBackendUserAuthentication) { // We need to set the workspace to live here $GLOBALS['BE_USER']->setTemporaryWorkspace(0); // Register the backend user as aspect @@ -205,8 +205,8 @@ class WorkspacePreview implements MiddlewareInterface throw new \Exception('POST requests are incompatible with keyword preview.', 1294585191); } // Validate configuration - $previewConfig = json_decode($previewData['config'], true); - if (!$previewConfig['fullWorkspace']) { + $previewConfig = json_decode($previewData['config'] ?? '', true); + if (!isset($previewConfig['fullWorkspace']) || !$previewConfig['fullWorkspace']) { throw new \Exception('Preview configuration did not include a workspace preview', 1294585190); } return (int)$previewConfig['fullWorkspace']; @@ -409,12 +409,9 @@ class WorkspacePreview implements MiddlewareInterface return $url->withQuery($queryString); } - /** - * @return LanguageService - */ protected function getLanguageService(): LanguageService { - return $GLOBALS['LANG'] ?: GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); + return $GLOBALS['LANG'] ?? GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } /** -- GitLab