[BUGFIX] Misinterpretation of memory_limit setting in install tool
authorMario Rimann <typo3-coding@rimann.org>
Sun, 4 Dec 2011 21:34:51 +0000 (22:34 +0100)
committerErnesto Baschny <ernst@cron-it.de>
Thu, 26 Jan 2012 15:23:04 +0000 (16:23 +0100)
Adds a different warning into the system checks of the basic
configuration section of the install tool in case the memory_limit
is set to "-1" which means unlimited according to the PHP docs.

Change-Id: I9df642e0e92945927330eba9713dd866f50c53d3
Fixes: #20069
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/8709
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
t3lib/class.t3lib_div.php
typo3/sysext/install/mod/class.tx_install.php

index 02605ef..bdb79bd 100644 (file)
@@ -3234,18 +3234,13 @@ final class t3lib_div {
         * @return integer The bytes value (e.g. 102400)
         */
        public static function getBytesFromSizeMeasurement($measurement) {
+               $bytes = doubleval($measurement);
                if (stripos($measurement, 'G')) {
-                       $bytes = doubleval($measurement) * 1024 * 1024 * 1024;
-               } else {
-                       if (stripos($measurement, 'M')) {
-                               $bytes = doubleval($measurement) * 1024 * 1024;
-                       } else {
-                               if (stripos($measurement, 'K')) {
-                                       $bytes = doubleval($measurement) * 1024;
-                               } else {
-                                       $bytes = doubleval($measurement);
-                               }
-                       }
+                       $bytes *= 1024 * 1024 * 1024;
+               } elseif (stripos($measurement, 'M')) {
+                       $bytes *= 1024 * 1024;
+               } elseif (stripos($measurement, 'K')) {
+                       $bytes *= 1024;
                }
                return $bytes;
        }
index e9f6d6c..42bae8e 100644 (file)
@@ -2240,7 +2240,18 @@ REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndp
                        // *****************
                $memory_limit_value = t3lib_div::getBytesFromSizeMeasurement(ini_get('memory_limit'));
 
-               if ($memory_limit_value && $memory_limit_value < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT)) {
+               if ($memory_limit_value <= 0) {
+                       $this->message(
+                               $ext,
+                               'Unlimited memory limit!',
+                               '<p>Your webserver is configured to not limit PHP memory usage at all. This is a risk
+                               and should be avoided in production setup. In general it\'s best practice to limit this
+                               in the configuration of your webserver. To be safe, ask the system administrator of the
+                               webserver to raise the limit to something over ' . TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT .
+                               '.</p>',
+                               2
+                       );
+               } elseif ($memory_limit_value < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT)) {
                        $this->message($ext, 'Memory limit below ' . TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT, '
                                <p>
                                        <em>memory_limit=' . ini_get('memory_limit') . '</em>
@@ -2254,15 +2265,10 @@ REMOTE_ADDR was '".t3lib_div::getIndpEnv('REMOTE_ADDR')."' (".t3lib_div::getIndp
                                        ' . TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT . '.
                                </p>
                        ', 3);
-               } elseif(!$memory_limit_value) {
-                       $this->message($ext, 'Memory limit', '
-                               <p>
-                                       <em>No memory limit in effect.</em>
-                               </p>
-                       ', -1);
                } else {
                        $this->message($ext, 'Memory limit: ' . ini_get('memory_limit'), '', -1);
                }
+
                if (ini_get('max_execution_time')<30) {
                        $this->message($ext, 'Maximum execution time below 30 seconds', '
                                <p>