[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)
committerTolleiv Nietsch <info@tolleiv.de>
Sat, 14 Jan 2012 10:58:09 +0000 (11:58 +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: I79e43d2e4300bce5d673296a844b9bd3416cd3da
Fixes: #32231
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/7040
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Wouter Wolters
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
typo3/sysext/reports/reports/locallang.xlf
typo3/sysext/reports/reports/status/class.tx_reports_reports_status_systemstatus.php

index f10b8c9..d452d7d 100644 (file)
                        <trans-unit id="status_phpMemoryContactAdmin" xml:space="preserve">
                                <source>Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.</source>
                        </trans-unit>
+                       <trans-unit id="status_phpMemoryUnlimited" xml:space="preserve">
+                               <source>unlimited</source>
+                       </trans-unit>
                        <trans-unit id="status_phpPeakMemory" xml:space="preserve">
                                <source>PHP peak memory usage</source>
                        </trans-unit>
index 53684c2..1c06922 100644 (file)
@@ -88,29 +88,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
                );
        }