[TASK] Check PCRE version in SystemEnvironment/Check 84/36784/5
authorStephan Großberndt <stephan@grossberndt.de>
Mon, 9 Feb 2015 19:35:36 +0000 (20:35 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 9 Feb 2015 21:03:14 +0000 (22:03 +0100)
Certain regular expressions passed to PCRE library < 8.30
can trigger a PHP segfault. This patch introduces an additional
system environment check to verify the PCRE version is
>= 8.30 (default shipped with PHP 5.5).

Resolves: #64950
Related: #62463
Releases: master
Change-Id: I3725c67f2b8e99941f0c6eb82a64d646025a1b85
Reviewed-on: http://review.typo3.org/36784
Reviewed-by: Stephan Großberndt <stephan@grossberndt.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
INSTALL.md
typo3/sysext/install/Classes/SystemEnvironment/Check.php

index a3e7d96..0938370 100644 (file)
@@ -64,7 +64,7 @@ check if these are available.
   * filter
   * hash
   * openssl
-  * pcre
+  * pcre >= 8.30
   * session
   * soap
   * SPL
@@ -291,4 +291,4 @@ A:  Fluid uses complex regular expressions which require a lot of stack space
                ThreadStackSize 8388608
        </IfModule>
 ```
-    Restart Apache after this change.
+    Restart Apache after this change.
\ No newline at end of file
index a4a83f6..8bd9e8d 100644 (file)
@@ -59,7 +59,6 @@ class Check {
                'json',
                'mysqli',
                'openssl',
-               'pcre',
                'session',
                'soap',
                'SPL',
@@ -108,6 +107,7 @@ class Check {
                foreach ($this->requiredPhpExtensions as $extension) {
                        $statusArray[] = $this->checkRequiredPhpExtension($extension);
                }
+               $statusArray[] = $this->checkPcreVersion();
                $statusArray[] = $this->checkGdLibTrueColorSupport();
                $statusArray[] = $this->checkGdLibGifSupport();
                $statusArray[] = $this->checkGdLibJpgSupport();
@@ -292,6 +292,40 @@ class Check {
        }
 
        /**
+        * Check PRCE module is loaded and minimum version
+        *
+        * @return Status\StatusInterface
+        */
+       protected function checkPcreVersion() {
+               $minimumPcreVersion = '8.30';
+               if (!extension_loaded('pcre')) {
+                       $status = new Status\ErrorStatus();
+                       $status->setTitle('PHP extension pcre not loaded');
+                       $status->setMessage(
+                               'TYPO3 CMS uses PHP extension pcre but it is not loaded' .
+                               ' in your environment. Change your environment to provide this extension' .
+                               ' in with minimum version ' . $minimumPcreVersion . '.'
+                       );
+               } else {
+                       $installedPcreVersionString = trim(PCRE_VERSION); // '8.31 2012-07-06'
+                       $mainPcreVersionString = explode(' ', $installedPcreVersionString);
+                       $mainPcreVersionString = $mainPcreVersionString[0]; // '8.31'
+                       if (version_compare($mainPcreVersionString, $minimumPcreVersion) < 0) {
+                               $status = new Status\ErrorStatus();
+                               $status->setTitle('PCRE version too low');
+                               $status->setMessage(
+                                       'Your PCRE version ' . PCRE_VERSION . ' is too old. TYPO3 CMS may trigger PHP segmentantion' .
+                                       ' faults with this version. Update to at least PCRE ' . $minimumPcreVersion
+                               );
+                       } else {
+                               $status = new Status\OkStatus();
+                               $status->setTitle('PHP extension PCRE is loaded and version is fine');
+                       }
+               }
+               return $status;
+       }
+
+       /**
         * Check maximum execution time
         *
         * @return Status\StatusInterface
@@ -1398,4 +1432,4 @@ class Check {
                return (int)$bytes;
        }
 
-}
+}
\ No newline at end of file