[CLEANUP] Code cleanup in ext:reports 59/45559/5
authorDaniel Goerz <ervaude@gmail.com>
Sun, 3 Jan 2016 21:12:26 +0000 (22:12 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 8 Jan 2016 18:27:28 +0000 (19:27 +0100)
* Use getter for $GLOBALS
* Use use-statements to avoid fully qualified class names
* Add missing @return annotations

Change-Id: Ie49fc42a33677a0de451becf12c06fe883dac8a2
Resolves: #72513
Releases: master
Reviewed-on: https://review.typo3.org/45559
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
12 files changed:
typo3/sysext/reports/Classes/Controller/ReportController.php
typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php
typo3/sysext/reports/Classes/Report/Status/FalStatus.php
typo3/sysext/reports/Classes/Report/Status/SecurityStatus.php
typo3/sysext/reports/Classes/Report/Status/Status.php
typo3/sysext/reports/Classes/Report/Status/SystemStatus.php
typo3/sysext/reports/Classes/Report/Status/Typo3Status.php
typo3/sysext/reports/Classes/Report/Status/WarningMessagePostProcessor.php
typo3/sysext/reports/Classes/Status.php
typo3/sysext/reports/Classes/Task/SystemStatusUpdateTask.php
typo3/sysext/reports/Classes/Task/SystemStatusUpdateTaskNotificationEmailField.php
typo3/sysext/reports/Classes/ViewHelpers/IconViewHelper.php

index 0033a3e..a6db91c 100644 (file)
@@ -90,9 +90,7 @@ class ReportController extends ActionController
      */
     public function indexAction()
     {
-        $this->view->assign(
-            'reports', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']
-        );
+        $this->view->assign('reports', $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']);
         $this->saveState();
     }
 
@@ -108,8 +106,7 @@ class ReportController extends ActionController
     {
         $content = ($error = '');
         $reportClass = null;
-        if (
-            isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension])
+        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension])
             && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension])
             && isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report])
             && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$extension][$report])
@@ -139,6 +136,8 @@ class ReportController extends ActionController
 
     /**
      * Generates the menu
+     *
+     * @return void
      */
     protected function generateMenu()
     {
@@ -158,8 +157,7 @@ class ReportController extends ActionController
             foreach ($reports as $reportName => $report) {
                 $menuItem = $menu
                     ->makeMenuItem()
-                    ->setHref($this->uriBuilder->reset()->uriFor('detail',
-                        array('extension' => $extKey, 'report' => $reportName), 'Report'))
+                    ->setHref($this->uriBuilder->reset()->uriFor('detail', array('extension' => $extKey, 'report' => $reportName), 'Report'))
                     ->setTitle($this->getLanguageService()->sL($report['title']));
                 if ($this->arguments->hasArgument('extension') && $this->arguments->hasArgument('report')) {
                     if ($this->arguments->getArgument('extension')->getValue() === $extKey && $this->arguments->getArgument('report')->getValue() === $reportName) {
@@ -175,6 +173,8 @@ class ReportController extends ActionController
 
     /**
      * Gets all buttons for the docheader
+     *
+     * @return void
      */
     protected function generateButtons()
     {
@@ -204,11 +204,11 @@ class ReportController extends ActionController
      */
     protected function saveState($extension = '', $report = '')
     {
-        $GLOBALS['BE_USER']->uc['reports']['selection'] = array(
+        $this->getBackendUser()->uc['reports']['selection'] = array(
             'extension' => $extension,
             'report' => $report,
         );
-        $GLOBALS['BE_USER']->writeUC();
+        $this->getBackendUser()->writeUC();
     }
 
     /**
index 2356315..d9dce77 100644 (file)
@@ -14,12 +14,21 @@ namespace TYPO3\CMS\Reports\Report\Status;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Messaging\FlashMessageService;
+use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Reports\Status;
+use TYPO3\CMS\Reports\StatusProviderInterface;
 
 /**
  * Performs some checks about the install tool protection status
  */
-class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
+class ConfigurationStatus implements StatusProviderInterface
 {
     /**
      * 10MB
@@ -71,19 +80,19 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getReferenceIndexStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
-        $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_refindex');
-        $registry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);
+        $severity = Status::OK;
+        $count = $this->getDatabaseConnection()->exec_SELECTcountRows('*', 'sys_refindex');
+        $registry = GeneralUtility::makeInstance(Registry::class);
         $lastRefIndexUpdate = $registry->get('core', 'sys_refindex_lastUpdate');
         if (!$count && $lastRefIndexUpdate) {
-            $value = $GLOBALS['LANG']->getLL('status_empty');
-            $severity = \TYPO3\CMS\Reports\Status::WARNING;
-            $url =  \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('system_dbint') . '&id=0&SET[function]=refindex';
-            $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_reference_index'), '<a href="' . htmlspecialchars($url) . '">', '</a>', \TYPO3\CMS\Backend\Utility\BackendUtility::dateTime($lastRefIndexUpdate));
+            $value = $this->getLanguageService()->getLL('status_empty');
+            $severity = Status::WARNING;
+            $url =  BackendUtility::getModuleUrl('system_dbint') . '&id=0&SET[function]=refindex';
+            $message = sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_reference_index'), '<a href="' . htmlspecialchars($url) . '">', '</a>', BackendUtility::dateTime($lastRefIndexUpdate));
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_referenceIndex'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_referenceIndex'), $value, $message, $severity);
     }
 
     /**
@@ -131,9 +140,9 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getMemcachedConnectionStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         $failedConnections = array();
         $defaultMemcachedPort = ini_get('memcache.default_port');
         $memcachedServers = $this->getConfiguredMemcachedServers();
@@ -163,11 +172,11 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
             }
         }
         if (!empty($failedConnections)) {
-            $value = $GLOBALS['LANG']->getLL('status_connectionFailed');
-            $severity = \TYPO3\CMS\Reports\Status::WARNING;
-            $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.memcache_not_usable') . '<br /><br />' . '<ul><li>' . implode('</li><li>', $failedConnections) . '</li></ul>';
+            $value = $this->getLanguageService()->getLL('status_connectionFailed');
+            $severity = Status::WARNING;
+            $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.memcache_not_usable') . '<br /><br />' . '<ul><li>' . implode('</li><li>', $failedConnections) . '</li></ul>';
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_memcachedConfiguration'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_memcachedConfiguration'), $value, $message, $severity);
     }
 
     /**
@@ -178,30 +187,30 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getDeprecationLogStatus()
     {
-        $title = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLog');
-        $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:disabled');
+        $title = $this->getLanguageService()->getLL('status_configuration_DeprecationLog');
+        $value = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:disabled');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
-            $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:enabled');
-            $message = '<p>' . $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogEnabled') . '</p>';
-            $severity = \TYPO3\CMS\Reports\Status::NOTICE;
+            $value = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:enabled');
+            $message = '<p>' . $this->getLanguageService()->getLL('status_configuration_DeprecationLogEnabled') . '</p>';
+            $severity = Status::NOTICE;
             $logFile = GeneralUtility::getDeprecationLogFileName();
             $logFileSize = 0;
             if (@file_exists($logFile)) {
                 $logFileSize = filesize($logFile);
-                $message .= '<p>' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogFile'), $this->getDeprecationLogFileLink()) . '</p>';
+                $message .= '<p>' . sprintf($this->getLanguageService()->getLL('status_configuration_DeprecationLogFile'), $this->getDeprecationLogFileLink()) . '</p>';
                 $removeDeprecationLogFileUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&amp;adminCmd=removeDeprecationLogFile';
-                $message .= '<p>' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogSize'), GeneralUtility::formatSize($logFileSize)) . ' <a href="' . $removeDeprecationLogFileUrl . '">' . $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogDeleteLink') . '</a></p>';
+                $message .= '<p>' . sprintf($this->getLanguageService()->getLL('status_configuration_DeprecationLogSize'), GeneralUtility::formatSize($logFileSize)) . ' <a href="' . $removeDeprecationLogFileUrl . '">' . $this->getLanguageService()->getLL('status_configuration_DeprecationLogDeleteLink') . '</a></p>';
             }
             if ($logFileSize > $this->deprecationLogFileSizeWarningThreshold) {
-                $severity = \TYPO3\CMS\Reports\Status::WARNING;
+                $severity = Status::WARNING;
             }
             if ($logFileSize > $this->deprecationLogFileSizeErrorThreshold) {
-                $severity = \TYPO3\CMS\Reports\Status::ERROR;
+                $severity = Status::ERROR;
             }
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $title, $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $title, $value, $message, $severity);
     }
 
     /**
@@ -211,15 +220,15 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getCreatedFilesWorldWritableStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         if ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] % 10 & 2) {
             $value = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'];
-            $severity = \TYPO3\CMS\Reports\Status::WARNING;
-            $message = $GLOBALS['LANG']->getLL('status_CreatedFilePermissions.writable');
+            $severity = Status::WARNING;
+            $message = $this->getLanguageService()->getLL('status_CreatedFilePermissions.writable');
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_CreatedFilePermissions'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_CreatedFilePermissions'), $value, $message, $severity);
     }
 
     /**
@@ -229,15 +238,15 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getCreatedDirectoriesWorldWritableStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         if ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] % 10 & 2) {
             $value = $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'];
-            $severity = \TYPO3\CMS\Reports\Status::WARNING;
-            $message = $GLOBALS['LANG']->getLL('status_CreatedDirectoryPermissions.writable');
+            $severity = Status::WARNING;
+            $message = $this->getLanguageService()->getLL('status_CreatedDirectoryPermissions.writable');
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_CreatedDirectoryPermissions'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_CreatedDirectoryPermissions'), $value, $message, $severity);
     }
 
     /**
@@ -249,7 +258,7 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
     protected function getDeprecationLogFileLink()
     {
         $logFile = GeneralUtility::getDeprecationLogFileName();
-        $relativePath = GeneralUtility::resolveBackPath($this->backPath . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($logFile));
+        $relativePath = GeneralUtility::resolveBackPath($this->backPath . PathUtility::stripPathSitePrefix($logFile));
         $link = '<a href="' . $relativePath . '">' . $logFile . '</a>';
         return $link;
     }
@@ -283,16 +292,32 @@ class ConfigurationStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
     {
         if (@unlink(GeneralUtility::getDeprecationLogFileName())) {
             $message = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogDeletedSuccessful');
-            $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK;
+            $severity = FlashMessage::OK;
         } else {
             $message = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogDeletionFailed');
-            $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR;
+            $severity = FlashMessage::ERROR;
         }
-        $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $message, '', $severity, true);
-        /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
-        $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
-        /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
+        $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $message, '', $severity, true);
+        /** @var FlashMessageService $flashMessageService  */
+        $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
+        /** @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue $defaultFlashMessageQueue */
         $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
         $defaultFlashMessageQueue->enqueue($flashMessage);
     }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
+
+    /**
+     * @return DatabaseConnection
+     */
+    protected function getDatabaseConnection()
+    {
+        return $GLOBALS['TYPO3_DB'];
+    }
 }
index 86610d2..6d6344d 100644 (file)
@@ -14,12 +14,17 @@ namespace TYPO3\CMS\Reports\Report\Status;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Resource\StorageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Reports\Status;
+use TYPO3\CMS\Reports\StatusProviderInterface;
 
 /**
  * Performs several checks about the FAL status
  */
-class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
+class FalStatus implements StatusProviderInterface
 {
     /**
      * Determines the status of the FAL index.
@@ -41,18 +46,18 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getMissingFilesStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_none');
+        $value = $this->getLanguageService()->getLL('status_none');
         $count = 0;
         $maxFilesToShow = 100;
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
 
-        /** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */
-        $storageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class);
+        /** @var StorageRepository $storageRepository */
+        $storageRepository = GeneralUtility::makeInstance(StorageRepository::class);
         $storageObjects = $storageRepository->findAll();
         $storages = array();
 
-        /** @var $storageObject \TYPO3\CMS\Core\Resource\ResourceStorage */
+        /** @var \TYPO3\CMS\Core\Resource\ResourceStorage $storageObject */
         foreach ($storageObjects as $storageObject) {
 
             // We only check missing files for storages that are online
@@ -62,7 +67,7 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
         }
 
         if (!empty($storages)) {
-            $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+            $count = $this->getDatabaseConnection()->exec_SELECTcountRows(
                 '*',
                 'sys_file',
                 'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')'
@@ -70,10 +75,10 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
         }
 
         if ($count) {
-            $value = sprintf($GLOBALS['LANG']->getLL('status_missingFilesCount'), $count);
-            $severity = \TYPO3\CMS\Reports\Status::WARNING;
+            $value = sprintf($this->getLanguageService()->getLL('status_missingFilesCount'), $count);
+            $severity = Status::WARNING;
 
-            $files = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+            $files = $this->getDatabaseConnection()->exec_SELECTgetRows(
                 'identifier,storage',
                 'sys_file',
                 'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')',
@@ -82,7 +87,7 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
                 $maxFilesToShow
             );
 
-            $message = '<p>' . $GLOBALS['LANG']->getLL('status_missingFilesMessage') . '</p>';
+            $message = '<p>' . $this->getLanguageService()->getLL('status_missingFilesMessage') . '</p>';
             foreach ($files as $file) {
                 $message .= $storages[$file['storage']]->getName() . ' ' . $file['identifier'] . '<br />';
             }
@@ -92,6 +97,22 @@ class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
             }
         }
 
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_missingFiles'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_missingFiles'), $value, $message, $severity);
+    }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
+
+    /**
+     * @return DatabaseConnection
+     */
+    protected function getDatabaseConnection()
+    {
+        return $GLOBALS['TYPO3_DB'];
     }
 }
index 7d47465..50da32e 100644 (file)
@@ -15,8 +15,14 @@ namespace TYPO3\CMS\Reports\Report\Status;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\TypoScript\ConfigurationForm;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Reports\Status;
+use TYPO3\CMS\Saltedpasswords\Salt\SaltFactory;
+use TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility;
 use TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility;
 
 /**
@@ -49,16 +55,15 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getTrustedHostsPatternStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] === GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL) {
-            $value = $GLOBALS['LANG']->getLL('status_insecure');
-            $severity = \TYPO3\CMS\Reports\Status::ERROR;
-            $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_trustedhosts');
+            $value = $this->getLanguageService()->getLL('status_insecure');
+            $severity = Status::ERROR;
+            $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_trustedhosts');
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
-            $GLOBALS['LANG']->getLL('status_trustedHostsPattern'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_trustedHostsPattern'), $value, $message, $severity);
     }
 
     /**
@@ -68,17 +73,17 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getAdminAccountStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
-        $whereClause = 'username = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('admin', 'be_users') .
+        $severity = Status::OK;
+        $whereClause = 'username = ' . $this->getDatabaseConnection()->fullQuoteStr('admin', 'be_users') .
             BackendUtility::deleteClause('be_users');
-        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, username, password', 'be_users', $whereClause);
-        $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
+        $res = $this->getDatabaseConnection()->exec_SELECTquery('uid, username, password', 'be_users', $whereClause);
+        $row = $this->getDatabaseConnection()->sql_fetch_assoc($res);
         if (!empty($row)) {
             $secure = true;
-            /** @var $saltingObject \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface */
-            $saltingObject = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($row['password']);
+            /** @var \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface $saltingObject */
+            $saltingObject = SaltFactory::getSaltingInstance($row['password']);
             if (is_object($saltingObject)) {
                 if ($saltingObject->checkPassword('password', $row['password'])) {
                     $secure = false;
@@ -89,8 +94,8 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
                 $secure = false;
             }
             if (!$secure) {
-                $value = $GLOBALS['LANG']->getLL('status_insecure');
-                $severity = \TYPO3\CMS\Reports\Status::ERROR;
+                $value = $this->getLanguageService()->getLL('status_insecure');
+                $severity = Status::ERROR;
                 $editUserAccountUrl = BackendUtility::getModuleUrl(
                     'record_edit',
                     array(
@@ -98,13 +103,15 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
                         'returnUrl' => BackendUtility::getModuleUrl('system_ReportsTxreportsm1')
                     )
                 );
-                $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_admin'),
-                    '<a href="' . htmlspecialchars($editUserAccountUrl) . '">', '</a>');
+                $message = sprintf(
+                    $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_admin'),
+                    '<a href="' . htmlspecialchars($editUserAccountUrl) . '">',
+                    '</a>'
+                );
             }
         }
-        $GLOBALS['TYPO3_DB']->sql_free_result($res);
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
-            $GLOBALS['LANG']->getLL('status_adminUserAccount'), $value, $message, $severity);
+        $this->getDatabaseConnection()->sql_free_result($res);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_adminUserAccount'), $value, $message, $severity);
     }
 
     /**
@@ -114,18 +121,20 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getEncryptionKeyStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
-            $value = $GLOBALS['LANG']->getLL('status_insecure');
-            $severity = \TYPO3\CMS\Reports\Status::ERROR;
+            $value = $this->getLanguageService()->getLL('status_insecure');
+            $severity = Status::ERROR;
             $url = 'install/index.php?redirect_url=index.php' . urlencode('?TYPO3_INSTALL[type]=config#set_encryptionKey');
-            $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_encryption'),
-                '<a href="' . $url . '">', '</a>');
+            $message = sprintf(
+                $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_encryption'),
+                '<a href="' . $url . '">',
+                '</a>'
+            );
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
-            $GLOBALS['LANG']->getLL('status_encryptionKey'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_encryptionKey'), $value, $message, $severity);
     }
 
     /**
@@ -135,20 +144,21 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getFileDenyPatternStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         $defaultParts = GeneralUtility::trimExplode('|', FILE_DENY_PATTERN_DEFAULT, true);
         $givenParts = GeneralUtility::trimExplode('|', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'], true);
         $result = array_intersect($defaultParts, $givenParts);
         if ($defaultParts !== $result) {
-            $value = $GLOBALS['LANG']->getLL('status_insecure');
-            $severity = \TYPO3\CMS\Reports\Status::ERROR;
-            $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_pattern_partsNotPresent'),
-                '<br /><pre>' . htmlspecialchars(FILE_DENY_PATTERN_DEFAULT) . '</pre><br />');
+            $value = $this->getLanguageService()->getLL('status_insecure');
+            $severity = Status::ERROR;
+            $message = sprintf(
+                $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_pattern_partsNotPresent'),
+                '<br /><pre>' . htmlspecialchars(FILE_DENY_PATTERN_DEFAULT) . '</pre><br />'
+            );
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
-            $GLOBALS['LANG']->getLL('status_fileDenyPattern'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_fileDenyPattern'), $value, $message, $severity);
     }
 
     /**
@@ -159,32 +169,16 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getHtaccessUploadStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         if ($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] != FILE_DENY_PATTERN_DEFAULT
             && GeneralUtility::verifyFilenameAgainstDenyPattern('.htaccess')) {
-            $value = $GLOBALS['LANG']->getLL('status_insecure');
-            $severity = \TYPO3\CMS\Reports\Status::ERROR;
-            $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_htaccess');
+            $value = $this->getLanguageService()->getLL('status_insecure');
+            $severity = Status::ERROR;
+            $message = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_htaccess');
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
-            $GLOBALS['LANG']->getLL('status_htaccessUploadProtection'), $value, $message, $severity);
-    }
-
-    /**
-     * Checks whether memcached is configured, if that's the case we assume it's also used.
-     *
-     * @return bool TRUE if memcached is used, FALSE otherwise.
-     */
-    protected function isMemcachedUsed()
-    {
-        $memcachedUsed = false;
-        $memcachedServers = $this->getConfiguredMemcachedServers();
-        if (!empty($memcachedServers)) {
-            $memcachedUsed = true;
-        }
-        return $memcachedUsed;
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_htaccessUploadProtection'), $value, $message, $severity);
     }
 
     /**
@@ -194,35 +188,35 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getSaltedPasswordsStatus()
     {
-        $value = $GLOBALS['LANG']->getLL('status_ok');
-        $severity = \TYPO3\CMS\Reports\Status::OK;
-        /** @var \TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility $configCheck */
-        $configCheck = GeneralUtility::makeInstance(\TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility::class);
-        $message = '<p>' . $GLOBALS['LANG']->getLL('status_saltedPasswords_infoText') . '</p>';
+        $value = $this->getLanguageService()->getLL('status_ok');
+        $severity = Status::OK;
+        /** @var ExtensionManagerConfigurationUtility $configCheck */
+        $configCheck = GeneralUtility::makeInstance(ExtensionManagerConfigurationUtility::class);
+        $message = '<p>' . $this->getLanguageService()->getLL('status_saltedPasswords_infoText') . '</p>';
         $messageDetail = '';
-        $resultCheck = $configCheck->checkConfigurationBackend(array(), new \TYPO3\CMS\Core\TypoScript\ConfigurationForm());
+        $resultCheck = $configCheck->checkConfigurationBackend(array(), new ConfigurationForm());
         switch ($resultCheck['errorType']) {
             case FlashMessage::INFO:
                 $messageDetail .= $resultCheck['html'];
                 break;
-            case FlashMessage::WARNING;
-                $severity = \TYPO3\CMS\Reports\Status::WARNING;
+            case FlashMessage::WARNING:
+                $severity = Status::WARNING;
                 $messageDetail .= $resultCheck['html'];
                 break;
             case FlashMessage::ERROR:
-                $value = $GLOBALS['LANG']->getLL('status_insecure');
-                $severity = \TYPO3\CMS\Reports\Status::ERROR;
+                $value = $this->getLanguageService()->getLL('status_insecure');
+                $severity = Status::ERROR;
                 $messageDetail .= $resultCheck['html'];
                 break;
             default:
         }
         $unsecureUserCount = SaltedPasswordsUtility::getNumberOfBackendUsersWithInsecurePassword();
         if ($unsecureUserCount > 0) {
-            $value = $GLOBALS['LANG']->getLL('status_insecure');
-            $severity = \TYPO3\CMS\Reports\Status::ERROR;
+            $value = $this->getLanguageService()->getLL('status_insecure');
+            $severity = Status::ERROR;
             $messageDetail .= '<div class="panel panel-warning">' .
                 '<div class="panel-body">' .
-                    $GLOBALS['LANG']->getLL('status_saltedPasswords_notAllPasswordsHashed') .
+                    $this->getLanguageService()->getLL('status_saltedPasswords_notAllPasswordsHashed') .
                 '</div>' .
             '</div>';
         }
@@ -230,7 +224,22 @@ class SecurityStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
         if (empty($messageDetail)) {
             $message = '';
         }
-        return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
-            $GLOBALS['LANG']->getLL('status_saltedPasswords'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_saltedPasswords'), $value, $message, $severity);
+    }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
+
+    /**
+     * @return DatabaseConnection
+     */
+    protected function getDatabaseConnection()
+    {
+        return $GLOBALS['TYPO3_DB'];
     }
 }
index cddb62b..23ec139 100644 (file)
@@ -14,8 +14,12 @@ namespace TYPO3\CMS\Reports\Report\Status;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Registry;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Reports\ExtendedStatusProviderInterface;
 use TYPO3\CMS\Reports\ReportInterface;
+use TYPO3\CMS\Reports\Status as ReportStatus;
 use TYPO3\CMS\Reports\StatusProviderInterface;
 
 /**
@@ -34,7 +38,7 @@ class Status implements ReportInterface
     public function __construct()
     {
         $this->getStatusProviders();
-        $GLOBALS['LANG']->includeLLFile('EXT:reports/Resources/Private/Language/locallang_reports.xlf');
+        $this->getLanguageService()->includeLLFile('EXT:reports/Resources/Private/Language/locallang_reports.xlf');
     }
 
     /**
@@ -48,9 +52,9 @@ class Status implements ReportInterface
         $status = $this->getSystemStatus();
         $highestSeverity = $this->getHighestSeverity($status);
         // Updating the registry
-        $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);
+        $registry = GeneralUtility::makeInstance(Registry::class);
         $registry->set('tx_reports', 'status.highestSeverity', $highestSeverity);
-        $content .= '<p class="lead">' . $GLOBALS['LANG']->getLL('status_report_explanation') . '</p>';
+        $content .= '<p class="lead">' . $this->getLanguageService()->getLL('status_report_explanation') . '</p>';
         return $content . $this->renderStatus($status);
     }
 
@@ -64,7 +68,7 @@ class Status implements ReportInterface
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers'] as $key => $statusProvidersList) {
             $this->statusProviders[$key] = array();
             foreach ($statusProvidersList as $statusProvider) {
-                $statusProviderInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($statusProvider);
+                $statusProviderInstance = GeneralUtility::makeInstance($statusProvider);
                 if ($statusProviderInstance instanceof StatusProviderInterface) {
                     $this->statusProviders[$key][] = $statusProviderInstance;
                 }
@@ -118,15 +122,15 @@ class Status implements ReportInterface
      */
     public function getHighestSeverity(array $statusCollection)
     {
-        $highestSeverity = \TYPO3\CMS\Reports\Status::NOTICE;
+        $highestSeverity = ReportStatus::NOTICE;
         foreach ($statusCollection as $statusProvider => $providerStatuses) {
-            /** @var $status \TYPO3\CMS\Reports\Status */
+            /** @var ReportStatus $status */
             foreach ($providerStatuses as $status) {
                 if ($status->getSeverity() > $highestSeverity) {
                     $highestSeverity = $status->getSeverity();
                 }
                 // Reached the highest severity level, no need to go on
-                if ($highestSeverity == \TYPO3\CMS\Reports\Status::ERROR) {
+                if ($highestSeverity == ReportStatus::ERROR) {
                     break;
                 }
             }
@@ -155,14 +159,14 @@ class Status implements ReportInterface
             $providerState = $this->sortStatuses($providerStatus);
             $id++;
             $classes = array(
-                \TYPO3\CMS\Reports\Status::NOTICE => 'notice',
-                \TYPO3\CMS\Reports\Status::INFO => 'info',
-                \TYPO3\CMS\Reports\Status::OK => 'success',
-                \TYPO3\CMS\Reports\Status::WARNING => 'warning',
-                \TYPO3\CMS\Reports\Status::ERROR => 'danger'
+                ReportStatus::NOTICE => 'notice',
+                ReportStatus::INFO => 'info',
+                ReportStatus::OK => 'success',
+                ReportStatus::WARNING => 'warning',
+                ReportStatus::ERROR => 'danger'
             );
             $messages = '';
-            /** @var $status \TYPO3\CMS\Reports\Status */
+            /** @var ReportStatus $status */
             foreach ($providerState as $status) {
                 $severity = $status->getSeverity();
                 $messages .= strtr($template, array(
@@ -194,10 +198,10 @@ class Status implements ReportInterface
         // that must appear on top of the status report
         // Change their keys to localized collection titles
         $primaryStatuses = array(
-            $GLOBALS['LANG']->getLL('status_typo3') => $statusCollection['typo3'],
-            $GLOBALS['LANG']->getLL('status_system') => $statusCollection['system'],
-            $GLOBALS['LANG']->getLL('status_security') => $statusCollection['security'],
-            $GLOBALS['LANG']->getLL('status_configuration') => $statusCollection['configuration']
+            $this->getLanguageService()->getLL('status_typo3') => $statusCollection['typo3'],
+            $this->getLanguageService()->getLL('status_system') => $statusCollection['system'],
+            $this->getLanguageService()->getLL('status_security') => $statusCollection['security'],
+            $this->getLanguageService()->getLL('status_configuration') => $statusCollection['configuration']
         );
         unset($statusCollection['typo3'], $statusCollection['system'], $statusCollection['security'], $statusCollection['configuration']);
         // Assemble list of secondary status collections with left-over collections
@@ -208,10 +212,10 @@ class Status implements ReportInterface
             $label = '';
             if (strpos($statusProviderId, 'LLL:') === 0) {
                 // Label provided by extension
-                $label = $GLOBALS['LANG']->sL($statusProviderId);
+                $label = $this->getLanguageService()->sL($statusProviderId);
             } else {
                 // Generic label
-                $label = $GLOBALS['LANG']->getLL('status_' . $statusProviderId);
+                $label = $this->getLanguageService()->getLL('status_' . $statusProviderId);
             }
             $providerLabel = empty($label) ? $statusProviderId : $label;
             $secondaryStatuses[$providerLabel] = $collection;
@@ -233,7 +237,7 @@ class Status implements ReportInterface
         $statuses = array();
         $sortTitle = array();
         $header = null;
-        /** @var $status \TYPO3\CMS\Reports\Status */
+        /** @var ReportStatus $status */
         foreach ($statusCollection as $status) {
             if ($status->getTitle() === 'TYPO3') {
                 $header = $status;
@@ -249,4 +253,12 @@ class Status implements ReportInterface
         }
         return $statuses;
     }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
index 7962971..12c53f2 100644 (file)
@@ -13,11 +13,16 @@ namespace TYPO3\CMS\Reports\Report\Status;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Registry;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Reports\Status;
+use TYPO3\CMS\Reports\StatusProviderInterface;
 
 /**
  * Performs several checks about the system's health
  */
-class SystemStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
+class SystemStatus implements StatusProviderInterface
 {
     /**
      * Determines the Install Tool's status, mainly concerning its protection.
@@ -41,11 +46,11 @@ class SystemStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function executeAdminCommand()
     {
-        $command = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('adminCmd');
+        $command = GeneralUtility::_GET('adminCmd');
         switch ($command) {
             case 'clear_peak_memory_usage_flag':
-                /** @var $registry \TYPO3\CMS\Core\Registry */
-                $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);
+                /** @var Registry $registry */
+                $registry = GeneralUtility::makeInstance(Registry::class);
                 $registry->remove('core', 'reports-peakMemoryUsage');
                 break;
             default:
@@ -60,25 +65,25 @@ class SystemStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
      */
     protected function getPhpPeakMemoryStatus()
     {
-        /** @var $registry \TYPO3\CMS\Core\Registry */
-        $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);
+        /** @var Registry $registry */
+        $registry = GeneralUtility::makeInstance(Registry::class);
         $peakMemoryUsage = $registry->get('core', 'reports-peakMemoryUsage');
-        $memoryLimit = \TYPO3\CMS\Core\Utility\GeneralUtility::getBytesFromSizeMeasurement(ini_get('memory_limit'));
-        $value = $GLOBALS['LANG']->getLL('status_ok');
+        $memoryLimit = GeneralUtility::getBytesFromSizeMeasurement(ini_get('memory_limit'));
+        $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
-        $severity = \TYPO3\CMS\Reports\Status::OK;
+        $severity = Status::OK;
         $bytesUsed = $peakMemoryUsage['used'];
         $percentageUsed = $memoryLimit ? number_format($bytesUsed / $memoryLimit * 100, 1) . '%' : '?';
         $dateOfPeak = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $peakMemoryUsage['tstamp']);
         $urlOfPeak = '<a href="' . htmlspecialchars($peakMemoryUsage['url']) . '">' . htmlspecialchars($peakMemoryUsage['url']) . '</a>';
-        $clearFlagUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&amp;adminCmd=clear_peak_memory_usage_flag';
+        $clearFlagUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&amp;adminCmd=clear_peak_memory_usage_flag';
         if ($peakMemoryUsage['used']) {
-            $message = sprintf($GLOBALS['LANG']->getLL('status_phpPeakMemoryTooHigh'), \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($peakMemoryUsage['used']), $percentageUsed, \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($memoryLimit), $dateOfPeak, $urlOfPeak);
-            $message .= ' <a href="' . $clearFlagUrl . '">' . $GLOBALS['LANG']->getLL('status_phpPeakMemoryClearFlag') . '</a>.';
-            $severity = \TYPO3\CMS\Reports\Status::WARNING;
+            $message = sprintf($this->getLanguageService()->getLL('status_phpPeakMemoryTooHigh'), GeneralUtility::formatSize($peakMemoryUsage['used']), $percentageUsed, GeneralUtility::formatSize($memoryLimit), $dateOfPeak, $urlOfPeak);
+            $message .= ' <a href="' . $clearFlagUrl . '">' . $this->getLanguageService()->getLL('status_phpPeakMemoryClearFlag') . '</a>.';
+            $severity = Status::WARNING;
             $value = $percentageUsed;
         }
-        return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_phpPeakMemory'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_phpPeakMemory'), $value, $message, $severity);
     }
 
     /**
@@ -91,7 +96,7 @@ class SystemStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
         $modules = array();
         if (is_array(${$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['requiredPhpModules']})) {
             foreach (${$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['requiredPhpModules']} as $classData) {
-                $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classData);
+                $hookObject = GeneralUtility::getUserObj($classData);
                 $modules = $hookObject->setRequiredPhpModules($modules, $this);
             }
         }
@@ -105,22 +110,30 @@ class SystemStatus implements \TYPO3\CMS\Reports\StatusProviderInterface
                     }
                 }
                 if ($detectedSubmodules === false) {
-                    $missingPhpModules[] = sprintf($GLOBALS['LANG']->getLL('status_phpModulesGroup'), '(' . implode(', ', $module) . ')');
+                    $missingPhpModules[] = sprintf($this->getLanguageService()->getLL('status_phpModulesGroup'), '(' . implode(', ', $module) . ')');
                 }
             } elseif (!extension_loaded($module)) {
                 $missingPhpModules[] = $module;
             }
         }
         if (!empty($missingPhpModules)) {
-            $value = $GLOBALS['LANG']->getLL('status_phpModulesMissing');
-            $message = sprintf($GLOBALS['LANG']->getLL('status_phpModulesList'), implode(', ', $missingPhpModules));
-            $message .= ' ' . $GLOBALS['LANG']->getLL('status_phpModulesInfo');
-            $severity = \TYPO3\CMS\Reports\Status::ERROR;
+            $value = $this->getLanguageService()->getLL('status_phpModulesMissing');
+            $message = sprintf($this->getLanguageService()->getLL('status_phpModulesList'), implode(', ', $missingPhpModules));
+            $message .= ' ' . $this->getLanguageService()->getLL('status_phpModulesInfo');
+            $severity = Status::ERROR;
         } else {
-            $value = $GLOBALS['LANG']->getLL('status_phpModulesPresent');
+            $value = $this->getLanguageService()->getLL('status_phpModulesPresent');
             $message = '';
-            $severity = \TYPO3\CMS\Reports\Status::OK;
+            $severity = Status::OK;
         }
-        return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_phpModules'), $value, $message, $severity);
+        return GeneralUtility::makeInstance(Status::class, $this->getLanguageService()->getLL('status_phpModules'), $value, $message, $severity);
+    }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
     }
 }
index 12f139f..45c6e38 100644 (file)
@@ -13,13 +13,16 @@ namespace TYPO3\CMS\Reports\Report\Status;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Reports\Status as ReportStatus;
+use TYPO3\CMS\Reports\StatusProviderInterface;
 
 /**
  * Performs basic checks about the TYPO3 install
  */
-class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface
+class Typo3Status implements StatusProviderInterface
 {
     /**
      * Returns the status for this report
@@ -44,7 +47,7 @@ class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface
     protected function getOldXclassUsageStatus()
     {
         $message = '';
-        $value = $GLOBALS['LANG']->getLL('status_none');
+        $value = $this->getLanguageService()->getLL('status_none');
         $severity = ReportStatus::OK;
 
         $xclasses = array_merge(
@@ -54,15 +57,15 @@ class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface
 
         $numberOfXclasses = count($xclasses);
         if ($numberOfXclasses > 0) {
-            $value = sprintf($GLOBALS['LANG']->getLL('status_oldXclassUsageFound'), $numberOfXclasses);
-            $message = $GLOBALS['LANG']->getLL('status_oldXclassUsageFound_message') . '<br />';
+            $value = sprintf($this->getLanguageService()->getLL('status_oldXclassUsageFound'), $numberOfXclasses);
+            $message = $this->getLanguageService()->getLL('status_oldXclassUsageFound_message') . '<br />';
             $message .= '<ol><li>' . implode('</li><li>', $xclasses) . '</li></ol>';
             $severity = ReportStatus::NOTICE;
         }
 
         return GeneralUtility::makeInstance(
             ReportStatus::class,
-            $GLOBALS['LANG']->getLL('status_oldXclassUsage'),
+            $this->getLanguageService()->getLL('status_oldXclassUsage'),
             $value,
             $message,
             $severity
@@ -77,7 +80,7 @@ class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface
     protected function getRegisteredXclassStatus()
     {
         $message = '';
-        $value = $GLOBALS['LANG']->getLL('status_none');
+        $value = $this->getLanguageService()->getLL('status_none');
         $severity = ReportStatus::OK;
 
         $xclassFoundArray = array();
@@ -89,12 +92,12 @@ class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface
             }
         }
         if (!empty($xclassFoundArray)) {
-            $value = $GLOBALS['LANG']->getLL('status_xclassUsageFound');
-            $message = $GLOBALS['LANG']->getLL('status_xclassUsageFound_message') . '<br />';
+            $value = $this->getLanguageService()->getLL('status_xclassUsageFound');
+            $message = $this->getLanguageService()->getLL('status_xclassUsageFound_message') . '<br />';
             $message .= '<ol>';
             foreach ($xclassFoundArray as $originalClass => $xClassName) {
                 $messageDetail = sprintf(
-                    $GLOBALS['LANG']->getLL('status_xclassUsageFound_message_detail'),
+                    $this->getLanguageService()->getLL('status_xclassUsageFound_message_detail'),
                     $originalClass,
                     $xClassName
                 );
@@ -106,7 +109,7 @@ class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface
 
         return GeneralUtility::makeInstance(
             ReportStatus::class,
-            $GLOBALS['LANG']->getLL('status_xclassUsage'),
+            $this->getLanguageService()->getLL('status_xclassUsage'),
             $value,
             $message,
             $severity
@@ -121,21 +124,29 @@ class Typo3Status implements \TYPO3\CMS\Reports\StatusProviderInterface
     protected function getCompatibility6Status()
     {
         $message = '';
-        $value = $GLOBALS['LANG']->getLL('status_disabled');
+        $value = $this->getLanguageService()->getLL('status_disabled');
         $severity = ReportStatus::OK;
 
-        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('compatibility6')) {
-            $value = $GLOBALS['LANG']->getLL('status_enabled');
-            $message = $GLOBALS['LANG']->getLL('status_compatibility6Usage_message');
+        if (ExtensionManagementUtility::isLoaded('compatibility6')) {
+            $value = $this->getLanguageService()->getLL('status_enabled');
+            $message = $this->getLanguageService()->getLL('status_compatibility6Usage_message');
             $severity = ReportStatus::WARNING;
         }
 
         return GeneralUtility::makeInstance(
             ReportStatus::class,
-            $GLOBALS['LANG']->getLL('status_compatibility6Usage'),
+            $this->getLanguageService()->getLL('status_compatibility6Usage'),
             $value,
             $message,
             $severity
         );
     }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
index f1632b9..61354af 100644 (file)
@@ -13,6 +13,11 @@ namespace TYPO3\CMS\Reports\Report\Status;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Registry;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Reports\Status;
 
 /**
  * Post processes the warning messages found in about modules.
@@ -26,20 +31,22 @@ class WarningMessagePostProcessor
      * control over the system warning messages.
      *
      * @param array $warningMessages An array of messages related to already found issues.
+     * @return void
      */
     public function displayWarningMessages_postProcess(array &$warningMessages)
     {
-        if (!$GLOBALS['BE_USER']->isAdmin()) {
+        if (!$this->getBackendUser()->isAdmin()) {
             return;
         }
         // Get highest severity
-        $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);
+        /** @var Registry $registry */
+        $registry = GeneralUtility::makeInstance(Registry::class);
         $highestSeverity = $registry->get('tx_reports', 'status.highestSeverity', null);
         if (!is_null($highestSeverity)) {
-            if ($highestSeverity > \TYPO3\CMS\Reports\Status::OK) {
+            if ($highestSeverity > Status::OK) {
                 // Display a message that there's something wrong and that
                 // the admin should take a look at the detailed status report
-                $GLOBALS['LANG']->includeLLFile('EXT:reports/Resources/Private/Language/locallang_reports.xlf');
+                $this->getLanguageService()->includeLLFile('EXT:reports/Resources/Private/Language/locallang_reports.xlf');
                 $reportModuleIdentifier = 'system_ReportsTxreportsm1';
                 $reportModuleParameters = array(
                     'tx_reports_system_reportstxreportsm1[extension]=tx_reports',
@@ -48,10 +55,27 @@ class WarningMessagePostProcessor
                     'tx_reports_system_reportstxreportsm1[controller]=Report',
                 );
                 $warningMessages['tx_reports_status_notification'] = sprintf(
-                    $GLOBALS['LANG']->getLL('status_problemNotification'),
-                    '<a href="javascript:top.goToModule(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($reportModuleIdentifier) . ', 1, ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue('&' . implode('&', $reportModuleParameters)) . ');">', '</a>'
+                    $this->getLanguageService()->getLL('status_problemNotification'),
+                    '<a href="javascript:top.goToModule(' . GeneralUtility::quoteJSvalue($reportModuleIdentifier) . ', 1, ' . GeneralUtility::quoteJSvalue('&' . implode('&', $reportModuleParameters)) . ');">',
+                    '</a>'
                 );
             }
         }
     }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
+
+    /**
+     * @return BackendUserAuthentication
+     */
+    protected function getBackendUser()
+    {
+        return $GLOBALS['BE_USER'];
+    }
 }
index 061c84b..2979393 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Reports;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Utility\MathUtility;
 
 /**
  * A class representing a certain status
@@ -62,7 +63,7 @@ class Status
         $this->title = (string)$title;
         $this->value = (string)$value;
         $this->message = (string)$message;
-        $this->severity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
+        $this->severity = MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
     }
 
     /**
index 6d7e625..92d8739 100644 (file)
@@ -14,8 +14,11 @@ namespace TYPO3\CMS\Reports\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Mail\MailMessage;
+use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MailUtility;
+use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Reports\Status;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
 
@@ -41,9 +44,9 @@ class SystemStatusUpdateTask extends AbstractTask
      */
     public function execute()
     {
-        /** @var $registry \TYPO3\CMS\Core\Registry */
-        $registry = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Registry::class);
-        /** @var $statusReport \TYPO3\CMS\Reports\Report\Status\Status */
+        /** @var Registry $registry */
+        $registry = GeneralUtility::makeInstance(Registry::class);
+        /** @var \TYPO3\CMS\Reports\Report\Status\Status $statusReport */
         $statusReport = GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Report\Status\Status::class);
         $systemStatus = $statusReport->getDetailedSystemStatus();
         $highestSeverity = $statusReport->getHighestSeverity($systemStatus);
@@ -97,21 +100,29 @@ class SystemStatusUpdateTask extends AbstractTask
         foreach ($notificationEmails as $notificationEmail) {
             $sendEmailsTo[] = $notificationEmail;
         }
-        $subject = sprintf($GLOBALS['LANG']->getLL('status_updateTask_email_subject'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
-        $message = sprintf($GLOBALS['LANG']->getLL('status_problemNotification'), '', '');
+        $subject = sprintf($this->getLanguageService()->getLL('status_updateTask_email_subject'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
+        $message = sprintf($this->getLanguageService()->getLL('status_problemNotification'), '', '');
         $message .= CRLF . CRLF;
-        $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_site') . ': ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
+        $message .= $this->getLanguageService()->getLL('status_updateTask_email_site') . ': ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
         $message .= CRLF . CRLF;
-        $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_issues') . ': ' . CRLF;
+        $message .= $this->getLanguageService()->getLL('status_updateTask_email_issues') . ': ' . CRLF;
         $message .= implode(CRLF, $systemIssues);
         $message .= CRLF . CRLF;
         $from = MailUtility::getSystemFrom();
-        /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
-        $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
+        /** @var MailMessage $mail */
+        $mail = GeneralUtility::makeInstance(MailMessage::class);
         $mail->setFrom($from);
         $mail->setTo($sendEmailsTo);
         $mail->setSubject($subject);
         $mail->setBody($message);
         $mail->send();
     }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
index ea42763..7d9c2f9 100644 (file)
@@ -13,12 +13,18 @@ namespace TYPO3\CMS\Reports\Task;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Lang\LanguageService;
+use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
+use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
+use TYPO3\CMS\Scheduler\Task\AbstractTask;
 
 /**
  * Additional field to set the notification email address(es) for system health
  * issue notifications.
  */
-class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface
+class SystemStatusUpdateTaskNotificationEmailField implements AdditionalFieldProviderInterface
 {
     /**
      * Additional fields
@@ -42,9 +48,8 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
      * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
      * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => ''))
      */
-    public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
+    public function getAdditionalFields(array &$taskInfo, $task, SchedulerModuleController $schedulerModule)
     {
-        $fields = array('notificationEmail' => 'textarea');
         if ($schedulerModule->CMD == 'edit') {
             $taskInfo[$this->fieldPrefix . 'NotificationEmail'] = $task->getNotificationEmail();
         }
@@ -71,18 +76,18 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
      * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
      * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise
      */
-    public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
+    public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule)
     {
         $validInput = true;
-        $notificationEmails = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], true);
+        $notificationEmails = GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], true);
         foreach ($notificationEmails as $notificationEmail) {
-            if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($notificationEmail)) {
+            if (!GeneralUtility::validEmail($notificationEmail)) {
                 $validInput = false;
                 break;
             }
         }
         if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) {
-            $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
+            $schedulerModule->addMessage($this->getLanguageService()->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), FlashMessage::ERROR);
             $validInput = false;
         }
         return $validInput;
@@ -95,10 +100,10 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
      * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the scheduler backend module
      * @return void
      */
-    public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
+    public function saveAdditionalFields(array $submittedData, AbstractTask $task)
     {
-        if (!$task instanceof \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask) {
-            throw new \InvalidArgumentException('Expected a task of type ' . \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask::class . ', but got ' . get_class($task), 1295012802);
+        if (!$task instanceof SystemStatusUpdateTask) {
+            throw new \InvalidArgumentException('Expected a task of type ' . SystemStatusUpdateTask::class . ', but got ' . get_class($task), 1295012802);
         }
         $task->setNotificationEmail($submittedData[$this->fieldPrefix . 'NotificationEmail']);
     }
@@ -113,4 +118,12 @@ class SystemStatusUpdateTaskNotificationEmailField implements \TYPO3\CMS\Schedul
     {
         return $this->fieldPrefix . ucfirst($fieldName);
     }
+
+    /**
+     * @return LanguageService
+     */
+    protected function getLanguageService()
+    {
+        return $GLOBALS['LANG'];
+    }
 }
index d20236e..30b40af 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Reports\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
 use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
@@ -57,12 +59,12 @@ class IconViewHelper extends AbstractBackendViewHelper implements CompilableInte
         $title = $arguments['title'];
 
         if (!empty($icon)) {
-            $absIconPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFilename($icon);
+            $absIconPath = GeneralUtility::getFileAbsFilename($icon);
             if (file_exists($absIconPath)) {
                 $icon = '../' . str_replace(PATH_site, '', $absIconPath);
             }
         } else {
-            $icon = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('reports') . 'ext_icon.png';
+            $icon = ExtensionManagementUtility::extRelPath('reports') . 'ext_icon.png';
         }
         return '<img src="' . htmlspecialchars($icon) . '" width="16" height="16" title="' . htmlspecialchars($title) . '" alt="' . htmlspecialchars($title) . '" />';
     }