Commit 9690e129 authored by Simon Gilli's avatar Simon Gilli Committed by Christian Kuhn
Browse files

[BUGFIX] Access to not defined array key in install tool

In the install tool context $GLOBALS['BE_USER'] is not available
and any access must be avoided especially from PHP 8.0.

Resolves: #94418
Releases: master
Change-Id: I1df52aedd9ba1149e4009c9cc3a6707ba114c607
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69576


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent b088b928
......@@ -155,7 +155,10 @@ class FlashMessageQueue extends \SplQueue implements \JsonSerializable
if (is_array($flashMessages)) {
$flashMessages = array_map('json_encode', $flashMessages);
}
$this->getUserByContext()->setAndSaveSessionData($this->identifier, $flashMessages);
$user = $this->getUserByContext();
if ($user instanceof AbstractUserAuthentication) {
$user->setAndSaveSessionData($this->identifier, $flashMessages);
}
}
/**
......@@ -202,16 +205,17 @@ class FlashMessageQueue extends \SplQueue implements \JsonSerializable
}
/**
* Gets user object by context
* Gets user object by context.
* This class is also used in install tool, where $GLOBALS['BE_USER'] is not set and can be null.
*
* @return AbstractUserAuthentication
* @return AbstractUserAuthentication|null
*/
protected function getUserByContext()
protected function getUserByContext(): ?AbstractUserAuthentication
{
if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController && $GLOBALS['TSFE']->fe_user instanceof FrontendUserAuthentication) {
return $GLOBALS['TSFE']->fe_user;
}
return $GLOBALS['BE_USER'];
return $GLOBALS['BE_USER'] ?? null;
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment