[TASK] Make FrontendUserAuthenticationTest notice free 98/56298/5
authorJan Helke <typo3@helke.de>
Sat, 17 Mar 2018 12:51:47 +0000 (13:51 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 17 Mar 2018 16:44:59 +0000 (17:44 +0100)
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>
typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php

index 874a0a0..bb5ed44 100644 (file)
@@ -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)) {
index bf9f4c4..8596efd 100644 (file)
@@ -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)
index a96b089..e9453ee 100644 (file)
@@ -39,11 +39,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
      */
     protected $singletonInstances = [];
@@ -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);