[TASK] Install Tool: Check minimum MySQL version 68/42368/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 7 Aug 2015 11:57:11 +0000 (13:57 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 7 Aug 2015 12:14:19 +0000 (14:14 +0200)
Adds a check for the minimum MySQL version to the database environment.
This test is only executed after the first install has been completed
and the install tool is fully accessible.

Resolves: #59444
Releases: master
Change-Id: I8cdd1d94cc449df1d6599cfa8ac7e033a1d9194a
Reviewed-on: http://review.typo3.org/42368
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck.php

index 95c4c39..80adc32 100644 (file)
@@ -48,6 +48,7 @@ class DatabaseCheck {
                if ($this->isDbalEnabled() || !$this->getDatabaseConnection()) {
                        return $statusArray;
                }
+               $statusArray[] = $this->checkMysqlVersion();
                $statusArray[] = $this->checkInvalidSqlModes();
                return $statusArray;
        }
@@ -78,6 +79,36 @@ class DatabaseCheck {
        }
 
        /**
+        * Check minimum MySQL version
+        *
+        * @return Status\StatusInterface
+        */
+       protected function checkMysqlVersion() {
+               $minimumMysqlVersion = '5.5.0';
+               $currentMysqlVersion = '';
+               $resource = $this->getDatabaseConnection()->sql_query('SHOW VARIABLES LIKE \'version\';');
+               if ($resource !== FALSE) {
+                       $result = $this->getDatabaseConnection()->sql_fetch_row($resource);
+                       if (isset($result[1])) {
+                               $currentMysqlVersion = $result[1];
+                       }
+               }
+               if (version_compare($currentMysqlVersion, $minimumMysqlVersion) < 0) {
+                       $status = new Status\ErrorStatus();
+                       $status->setTitle('MySQL version too low');
+                       $status->setMessage(
+                               'Your MySQL version ' . $currentMysqlVersion . ' is too old. TYPO3 CMS does not run' .
+                               ' with this version. Update to at least MySQL ' . $minimumMysqlVersion
+                       );
+               } else {
+                       $status = new Status\OkStatus();
+                       $status->setTitle('MySQL version is fine');
+               }
+
+               return $status;
+       }
+
+       /**
         * Returns an array with the current sql mode settings
         *
         * @return array Contains all configured SQL modes that are incompatible