[BUGFIX] Unlimited memory limit handling in system status report
authorMario Rimann <typo3-coding@rimann.org>
Fri, 2 Dec 2011 21:10:25 +0000 (22:10 +0100)
committerSusanne Moog <typo3@susannemoog.de>
Sat, 28 Jan 2012 12:20:15 +0000 (13:20 +0100)
According to the documentation, "-1" is a valid setting for PHP's
memory_limit and means "unlimited". So far this value has caused
the system status report to report this value as an error.

Change-Id: I2fbdbf8b9e39dd0425253f5487b869bc81f52e27
Fixes: #32231
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/7793
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
typo3/sysext/reports/reports/locallang.xml
typo3/sysext/reports/reports/status/class.tx_reports_reports_status_systemstatus.php

index 84994ed..60f1bc9 100644 (file)
@@ -44,6 +44,7 @@
                        <label index="status_phpMemoryRequirement">Depending on your configuration, TYPO3 can run with a %1$s PHP memory limit. However, a %2$s PHP memory limit or above is required especially if your site uses additional extensions.</label>
                        <label index="status_phpMemoryEditLimit">Increase the memory limit by editing the memory_limit parameter in the file %s and then restart your web server (or contact your system administrator or hosting provider for assistance).</label>
                        <label index="status_phpMemoryContactAdmin">Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.</label>
+                       <label index="status_phpMemoryUnlimited">unlimited</label>
                        <label index="status_phpRegisterGlobals">PHP Register Globals</label>
                        <label index="status_phpRegisterGlobalsEnabled">%s is enabled. TYPO3 requires this configuration directive to be disabled.</label>
                        <label index="status_phpRegisterGlobalsSecurity">Your site may not be secure when %s is enabled.</label>
index e21dc53..7bc8d1d 100644 (file)
@@ -79,29 +79,36 @@ class tx_reports_reports_status_SystemStatus implements tx_reports_StatusProvide
         */
        protected function getPhpMemoryLimitStatus() {
                $memoryLimit = ini_get('memory_limit');
+               $memoryLimitBytes = t3lib_div::getBytesFromSizeMeasurement($memoryLimit);
                $message     = '';
                $severity    = tx_reports_reports_status_Status::OK;
 
-               if ($memoryLimit && t3lib_div::getBytesFromSizeMeasurement($memoryLimit) < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_RECOMMENDED_PHP_MEMORY_LIMIT)) {
-                       $message = sprintf($GLOBALS['LANG']->getLL('status_phpMemoryRecommendation'), $memoryLimit, TYPO3_REQUIREMENTS_RECOMMENDED_PHP_MEMORY_LIMIT);
-                       $severity = tx_reports_reports_status_Status::WARNING;
-               }
+               if ($memoryLimitBytes > 0) {
+                       if ($memoryLimitBytes < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_RECOMMENDED_PHP_MEMORY_LIMIT)) {
+                               $message = sprintf($GLOBALS['LANG']->getLL('status_phpMemoryRecommendation'), $memoryLimit, TYPO3_REQUIREMENTS_RECOMMENDED_PHP_MEMORY_LIMIT);
+                               $severity = tx_reports_reports_status_Status::WARNING;
+                       }
 
-               if ($memoryLimit && t3lib_div::getBytesFromSizeMeasurement($memoryLimit) < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT)) {
-                       $message = sprintf($GLOBALS['LANG']->getLL('status_phpMemoryRequirement'), $memoryLimit, TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT);
-                       $severity = tx_reports_reports_status_Status::ERROR;
-               }
+                       if ($memoryLimitBytes < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT)) {
+                               $message = sprintf($GLOBALS['LANG']->getLL('status_phpMemoryRequirement'), $memoryLimit, TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT);
+                               $severity = tx_reports_reports_status_Status::ERROR;
+                       }
 
-               if ($severity > tx_reports_reports_status_Status::OK) {
-                       if ($php_ini_path = get_cfg_var('cfg_file_path')) {
-                               $message .= ' ' . sprintf($GLOBALS['LANG']->getLL('status_phpMemoryEditLimit'), $php_ini_path);
-                       } else {
-                               $message .= ' ' . $GLOBALS['LANG']->getLL('status_phpMemoryContactAdmin');
+                       if ($severity > tx_reports_reports_status_Status::OK) {
+                               if ($php_ini_path = get_cfg_var('cfg_file_path')) {
+                                       $message .= ' ' . sprintf($GLOBALS['LANG']->getLL('status_phpMemoryEditLimit'), $php_ini_path);
+                               } else {
+                                       $message .= ' ' . $GLOBALS['LANG']->getLL('status_phpMemoryContactAdmin');
+                               }
                        }
                }
 
-               return t3lib_div::makeInstance('tx_reports_reports_status_Status',
-                       $GLOBALS['LANG']->getLL('status_phpMemory'), $memoryLimit, $message, $severity
+               return t3lib_div::makeInstance(
+                       'tx_reports_reports_status_Status',
+                       $GLOBALS['LANG']->getLL('status_phpMemory'),
+                       ($memoryLimitBytes > 0 ? $memoryLimit : $GLOBALS['LANG']->getLL('status_phpMemoryUnlimited')),
+                       $message,
+                       $severity
                );
        }