Skip to content

Commit

Permalink
[BUGFIX] Avoid PHP8 fatal errors in CommandLineUserAuthentication
Browse files Browse the repository at this point in the history
Releases: master
Resolves: #94592
Change-Id: I0616e362b598beb49859f5e78a3f2636f6cdf73f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69940
Tested-by: core-ci <typo3@b13.com>
Tested-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
  • Loading branch information
helhum committed Jul 20, 2021
1 parent e566f83 commit 8037908
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -1241,7 +1241,7 @@ public function setBeUserByUid($uid)
*/
public function setBeUserByName($name)
{
$this->user = $this->getRawUserByName($name);
$this->user = $this->getRawUserByName($name) ?: null;
}

/**
Expand Down
Expand Up @@ -90,7 +90,7 @@ public function authenticate()
{
// 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();
Expand All @@ -99,7 +99,7 @@ public function authenticate()
}
$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.
Expand Down Expand Up @@ -159,8 +159,8 @@ protected function createCliUser()
'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)
Expand Down

0 comments on commit 8037908

Please sign in to comment.