Commit 26198673 authored by Helmut Hummel's avatar Helmut Hummel
Browse files

[BUGFIX] Avoid PHP8 fatal errors in CommandLineUserAuthentication

Releases: master
Resolves: #94592
Change-Id: I0616e362b598beb49859f5e78a3f2636f6cdf73f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69969


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Helmut Hummel's avatarHelmut Hummel <typo3@helhum.io>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Helmut Hummel's avatarHelmut Hummel <typo3@helhum.io>
parent 5e676a21
......@@ -1241,7 +1241,7 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface
*/
public function setBeUserByName($name)
{
$this->user = $this->getRawUserByName($name);
$this->user = $this->getRawUserByName($name) ?: null;
}
/**
......
......@@ -90,7 +90,7 @@ class CommandLineUserAuthentication extends BackendUserAuthentication
{
// check if a _CLI_ user exists, if not, create one
$this->setBeUserByName($this->username);
if (!$this->user['uid']) {
if (empty($this->user['uid'])) {
// create a new BE user in the database
if (!$this->checkIfCliUserExists()) {
$this->createCliUser();
......@@ -99,7 +99,7 @@ class CommandLineUserAuthentication extends BackendUserAuthentication
}
$this->setBeUserByName($this->username);
}
if (!$this->user['uid']) {
if (empty($this->user['uid'])) {
throw new \RuntimeException('No backend user named "_cli_" could be created.', 1476107195);
}
// The groups are fetched and ready for permission checking in this initialization.
......@@ -159,8 +159,8 @@ class CommandLineUserAuthentication extends BackendUserAuthentication
'username' => $this->username,
'password' => $this->generateHashedPassword(),
'admin' => 1,
'tstamp' => $GLOBALS['EXEC_TIME'],
'crdate' => $GLOBALS['EXEC_TIME']
'tstamp' => $GLOBALS['EXEC_TIME'] ?? time(),
'crdate' => $GLOBALS['EXEC_TIME'] ?? time(),
];
$databaseConnection = GeneralUtility::makeInstance(ConnectionPool::class)
......
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