From 1adc484bacf17b57d323fdcbf22d02b3bdfd9e4d Mon Sep 17 00:00:00 2001 From: Jan Helke <typo3@helke.de> Date: Sat, 17 Mar 2018 13:51:47 +0100 Subject: [PATCH] [TASK] Make FrontendUserAuthenticationTest notice free Releases: master Resolves: #84429 Change-Id: I14ea2748297af9337328bd21326cb54a17845686 Reviewed-on: https://review.typo3.org/56298 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Classes/Authentication/AbstractUserAuthentication.php | 8 ++++---- typo3/sysext/core/Classes/Utility/GeneralUtility.php | 8 +++----- .../Authentication/FrontendUserAuthenticationTest.php | 6 +----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php b/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php index 874a0a01bc64..bb5ed44d0533 100644 --- a/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php +++ b/typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php @@ -613,8 +613,8 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface if ($haveSession) { $this->logger->debug('User session found', [ - $this->userid_column => $authInfo['userSession'][$this->userid_column], - $this->username_column => $authInfo['userSession'][$this->username_column], + $this->userid_column => $authInfo['userSession'][$this->userid_column] ?? null, + $this->username_column => $authInfo['userSession'][$this->username_column] ?? null, ]); } else { $this->logger->debug('No user session found'); @@ -639,13 +639,13 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface $this->username_column => $row[$this->username_column], ]); // User found, just stop to search for more if not configured to go on - if (!$this->svConfig['setup'][$this->loginType . '_fetchAllUsers']) { + if (empty($this->svConfig['setup'][$this->loginType . '_fetchAllUsers'])) { break; } } } - if ($this->svConfig['setup'][$this->loginType . '_alwaysFetchUser']) { + if (!empty($this->svConfig['setup'][$this->loginType . '_alwaysFetchUser'])) { $this->logger->debug($this->loginType . '_alwaysFetchUser option is enabled'); } if (empty($tempuserArr)) { diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index bf9f4c4fa78a..8596efd1d140 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -2676,8 +2676,8 @@ class GeneralUtility $retVal = self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP']); break; case 'REMOTE_ADDR': - $retVal = $_SERVER['REMOTE_ADDR']; - if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'] ?? '')) { + $retVal = $_SERVER['REMOTE_ADDR'] ?? null; + if (self::cmpIP($retVal, $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'] ?? '')) { $ip = self::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); // Choose which IP in list to use if (!empty($ip)) { @@ -2741,9 +2741,7 @@ class GeneralUtility case 'REMOTE_HOST': case 'QUERY_STRING': - if (isset($_SERVER[$getEnvName])) { - $retVal = $_SERVER[$getEnvName]; - } + $retVal = $_SERVER[$getEnvName] ?? ''; break; case 'TYPO3_DOCUMENT_ROOT': // Get the web root (it is not the root of the TYPO3 installation) diff --git a/typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php b/typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php index a96b08989208..e9453ee3cd0a 100644 --- a/typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php +++ b/typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php @@ -38,11 +38,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; */ class FrontendUserAuthenticationTest extends UnitTestCase { - /** - * Subject is not notice free, disable E_NOTICES - */ - protected static $suppressNotices = true; - /** * @var array A backup of registered singleton instances */ @@ -347,6 +342,7 @@ class FrontendUserAuthenticationTest extends UnitTestCase */ public function canLogUserInWithoutAnonymousSession() { + $GLOBALS['BE_USER'] = []; // This setup fakes the "getAuthInfoArray() db call $queryBuilderProphecy = $this->prophesize(QueryBuilder::class); $connectionPoolProphecy = $this->prophesize(ConnectionPool::class); -- GitLab