[TASK] Cleanup BackendUtitlity::displayWarningMessages 00/23400/5
authorKai Ole Hartwig <typo3review@ole-hartwig.eu>
Wed, 28 Aug 2013 12:30:33 +0000 (14:30 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 28 Aug 2013 18:03:36 +0000 (20:03 +0200)
As the report tool checks system environment with the use of the hook
witin that function, we can deprecate the function in the BackendUtility
and move the hook to the appropriate extension "aboutmodules".

Resolves: #51434
Releases: 6.2
Change-Id: If39a82680a8797782bcbf620d7a3e59193468a9c
Reviewed-on: https://review.typo3.org/23400
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/aboutmodules/Classes/Controller/ModulesController.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/reports/Classes/Report/Status/WarningMessagePostProcessor.php

index 763604e..ced3872 100644 (file)
@@ -42,11 +42,37 @@ class ModulesController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControll
         * @return void
         */
        public function indexAction() {
+               $warnings = array();
+               // Hook for additional warnings
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
+                               $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
+                               if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
+                                       $hookObj->displayWarningMessages_postProcess($warnings);
+                               }
+                       }
+               }
+               if (count($warnings)) {
+                       if (count($warnings) > 1) {
+                               $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
+                       } else {
+                               $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
+                       }
+                       $securityMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+                               'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
+                               $securityWarnings,
+                               $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.header'),
+                               \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
+                       );
+                       $contentWarnings = '<div style="margin: 20px 0px;">' . $securityMessage->render() . '</div>';
+                       unset($warnings);
+               }
+
                $this->view->assignMultiple(
                        array(
                                'TYPO3Version' => TYPO3_version,
                                'copyRightNotice' => \TYPO3\CMS\Backend\Utility\BackendUtility::TYPO3_copyRightNotice(),
-                               'warningMessages' => \TYPO3\CMS\Backend\Utility\BackendUtility::displayWarningMessages(),
+                               'warningMessages' => $contentWarnings,
                                'modules' => $this->getModulesData()
                        )
                );
index 67f52cc..620e734 100644 (file)
@@ -3942,136 +3942,12 @@ class BackendUtility {
         * These warnings are only displayed to admin users
         *
         * @return string Rendered messages as HTML
+        * @deprecated since 6.2 and is removed two versions later. This was transferred to ext:aboutmodules, do not use any longer!
+        * @see \TYPO3\CMS\Aboutmodules\Controller\ModulesController
         */
        static public function displayWarningMessages() {
-               if ($GLOBALS['BE_USER']->isAdmin()) {
-                       // Array containing warnings that must be displayed
-                       $warnings = array();
-                       // If this file exists and it isn't older than one hour, the Install Tool is enabled
-                       $enableInstallToolFile = PATH_site . 'typo3conf/ENABLE_INSTALL_TOOL';
-                       // Cleanup command, if set
-                       $cmd = GeneralUtility::_GET('adminWarning_cmd');
-                       switch ($cmd) {
-                               case 'remove_ENABLE_INSTALL_TOOL':
-                                       if (unlink($enableInstallToolFile)) {
-                                               unset($enableInstallToolFile);
-                                       }
-                                       break;
-                       }
-                       // Check if there is still a default user 'admin' with password 'password' (MD5sum = 5f4dcc3b5aa765d61d8327deb882cf99)
-                       $where_clause = 'username=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('admin', 'be_users') . ' AND password=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('5f4dcc3b5aa765d61d8327deb882cf99', 'be_users') . self::deleteClause('be_users');
-                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, username, password', 'be_users', $where_clause);
-                       if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                               $url = 'alt_doc.php?returnUrl=' . urlencode('mod.php?M=help_AboutmodulesAboutmodules') . '&edit[be_users][' . $row['uid'] . ']=edit';
-                               $warnings['backend_admin'] = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_admin'), '<a href="' . htmlspecialchars($url) . '">', '</a>');
-                       }
-                       $GLOBALS['TYPO3_DB']->sql_free_result($res);
-                       // Check whether the file ENABLE_INSTALL_TOOL contains the string "KEEP_FILE" which permanently unlocks the install tool
-                       if (is_file($enableInstallToolFile) && trim(file_get_contents($enableInstallToolFile)) === 'KEEP_FILE') {
-                               $url = GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT') . '?adminWarning_cmd=remove_ENABLE_INSTALL_TOOL';
-                               $warnings['install_enabled'] = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_enabled'), '<span style="white-space:nowrap;">' . $enableInstallToolFile . '</span>');
-                               $warnings['install_enabled'] .= ' <a href="' . $url . '">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
-                       }
-                       // Check if the encryption key is empty
-                       if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] == '') {
-                               $url = 'install/index.php?redirect_url=index.php' . urlencode('?TYPO3_INSTALL[type]=config#set_encryptionKey');
-                               $warnings['install_encryption'] = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_encryption'), '<a href="' . $url . '">', '</a>');
-                       }
-                       // Check if parts of fileDenyPattern were removed which is dangerous on Apache
-                       $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) {
-                               $warnings['file_deny_pattern'] = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_pattern_partsNotPresent'), '<br /><pre>' . htmlspecialchars(FILE_DENY_PATTERN_DEFAULT) . '</pre><br />');
-                       }
-                       // Check if fileDenyPattern allows to upload .htaccess files which is dangerous on Apache
-                       if ($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] != FILE_DENY_PATTERN_DEFAULT && GeneralUtility::verifyFilenameAgainstDenyPattern('.htaccess')) {
-                               $warnings['file_deny_htaccess'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_htaccess');
-                       }
-                       // Check if there are still updates to perform
-                       if (!GeneralUtility::compat_version(TYPO3_branch)) {
-                               $url = 'install/index.php?redirect_url=index.php' . urlencode('?TYPO3_INSTALL[type]=update');
-                               $warnings['install_update'] = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_update'), '<a href="' . $url . '">', '</a>');
-                       }
-                       // Check if sys_refindex is empty
-                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_refindex');
-                       $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
-                       $lastRefIndexUpdate = $registry->get('core', 'sys_refindex_lastUpdate');
-                       if (!$count && $lastRefIndexUpdate) {
-                               $url =  static::getModuleUrl('system_dbint') . '&id=0&SET[function]=refindex';
-                               $warnings['backend_reference'] = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_reference_index'), '<a href="' . $url . '">', '</a>', self::dateTime($lastRefIndexUpdate));
-                       }
-                       // Check for memcached if configured
-                       $memCacheUse = FALSE;
-                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'])) {
-                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $table => $conf) {
-                                       if (is_array($conf)) {
-                                               foreach ($conf as $key => $value) {
-                                                       if (!is_array($value) && $value === 'TYPO3\\CMS\\Core\\Cache\\Backend\\MemcachedBackend') {
-                                                               $servers = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$table]['options']['servers'];
-                                                               $memCacheUse = TRUE;
-                                                               break;
-                                                       }
-                                               }
-                                       }
-                               }
-                               if ($memCacheUse) {
-                                       $failed = array();
-                                       $defaultPort = ini_get('memcache.default_port');
-                                       if (function_exists('memcache_connect')) {
-                                               if (is_array($servers)) {
-                                                       foreach ($servers as $testServer) {
-                                                               $configuredServer = $testServer;
-                                                               if (substr($testServer, 0, 7) == 'unix://') {
-                                                                       $host = $testServer;
-                                                                       $port = 0;
-                                                               } else {
-                                                                       if (substr($testServer, 0, 6) === 'tcp://') {
-                                                                               $testServer = substr($testServer, 6);
-                                                                       }
-                                                                       if (strstr($testServer, ':') !== FALSE) {
-                                                                               list($host, $port) = explode(':', $testServer, 2);
-                                                                       } else {
-                                                                               $host = $testServer;
-                                                                               $port = $defaultPort;
-                                                                       }
-                                                               }
-                                                               $memcache_obj = @memcache_connect($host, $port);
-                                                               if ($memcache_obj != NULL) {
-                                                                       memcache_close($memcache_obj);
-                                                               } else {
-                                                                       $failed[] = $configuredServer;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                                       if (count($failed) > 0) {
-                                               $warnings['memcached'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.memcache_not_usable') . '<br/>' . implode(', ', $failed);
-                                       }
-                               }
-                       }
-                       // Hook for additional warnings
-                       if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
-                               foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
-                                       $hookObj = GeneralUtility::getUserObj($classRef);
-                                       if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
-                                               $hookObj->displayWarningMessages_postProcess($warnings);
-                                       }
-                               }
-                       }
-                       if (count($warnings)) {
-                               if (count($warnings) > 1) {
-                                       $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
-                               } else {
-                                       $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
-                               }
-                               $securityMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $securityWarnings, $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.header'), FlashMessage::ERROR);
-                               $content = '<div style="margin: 20px 0px;">' . $securityMessage->render() . '</div>';
-                               unset($warnings);
-                               return $content;
-                       }
-               }
-               return '<p>&nbsp;</p>';
+               GeneralUtility::logDeprecatedFunction();
+               return '';
        }
 
        /**
index 9b18fa1..bc1022e 100644 (file)
@@ -43,8 +43,6 @@ class WarningMessagePostProcessor {
                $registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
                $highestSeverity = $registry->get('tx_reports', 'status.highestSeverity', NULL);
                if (!is_null($highestSeverity)) {
-                       // Status update has run, so taking over control over the core messages
-                       unset($warningMessages['install_password'], $warningMessages['backend_admin'], $warningMessages['install_enabled'], $warningMessages['install_encryption'], $warningMessages['file_deny_pattern'], $warningMessages['file_deny_htaccess'], $warningMessages['install_update'], $warningMessages['backend_reference'], $warningMessages['memcached']);
                        if ($highestSeverity > \TYPO3\CMS\Reports\Status::OK) {
                                // Display a message that there's something wrong and that
                                // the admin should take a look at the detailed status report