Improved system requirements check
authorMarcel Werk <burntime@woltlab.com>
Tue, 11 Jun 2013 14:10:37 +0000 (16:10 +0200)
committerMarcel Werk <burntime@woltlab.com>
Tue, 11 Jun 2013 14:10:37 +0000 (16:10 +0200)
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/database/Database.class.php
wcfsetup/install/files/lib/system/database/MySQLDatabase.class.php

index 2660027be1cc29a8d939a62053310aecf75f04de..7f1145d4a91648f15344b00bcbd8875a3279d91f 100644 (file)
@@ -616,7 +616,7 @@ class WCFSetup extends WCF {
                                }
                                
                                // check connection data
-                               $db = new $dbClass($dbHost, $dbUser, $dbPassword, $dbName, $dbPort);
+                               $db = new $dbClass($dbHost, $dbUser, $dbPassword, $dbName, $dbPort, true);
                                $db->connect();
                                
                                $start = microtime(true);
@@ -624,12 +624,19 @@ class WCFSetup extends WCF {
                                
                                // check sql version
                                if (!empty($availableDBClasses[$dbClass]['minversion'])) {
-                                       $sqlVersion = $db->getVersion();
-                                       if ($sqlVersion != 'unknown') {
-                                               $compareSQLVersion = preg_replace('/^(\d+\.\d+\.\d+).*$/', '\\1', $sqlVersion);
-                                               if (!(version_compare($compareSQLVersion, $availableDBClasses[$dbClass]['minversion']) >= 0)) {
-                                                       throw new SystemException("Insufficient SQL version '".$compareSQLVersion."'. Version '".$availableDBClasses[$dbClass]['minversion']."' or greater is needed.");
-                                               }
+                                       $compareSQLVersion = preg_replace('/^(\d+\.\d+\.\d+).*$/', '\\1', $db->getVersion());
+                                       if (!(version_compare($compareSQLVersion, $availableDBClasses[$dbClass]['minversion']) >= 0)) {
+                                               throw new SystemException("Insufficient SQL version '".$compareSQLVersion."'. Version '".$availableDBClasses[$dbClass]['minversion']."' or greater is needed.");
+                                       }
+                               }
+                               // check innodb support
+                               if ($dbClass == 'MySQLDatabase') {
+                                       $sql = "SHOW VARIABLES WHERE Variable_name = 'have_innodb'";
+                                       $statement = $db->prepareStatement($sql);
+                                       $statement->execute();
+                                       $row = $statement->fetchArray();
+                                       if ($row !== false || $row['Value'] != 'YES') {
+                                               throw new SystemException("Support for InnoDB is missing.");
                                        }
                                }
                                
index c4c21cfbf23f10d5201bb8f82d3622ba05ec6b30..702160cee96c329fdf3c6d23a39d454362c4bd25 100644 (file)
@@ -56,6 +56,12 @@ abstract class Database {
         */
        protected $database = '';
        
+       /**
+        * enables failsafe connection
+        * @var boolean
+        */
+       protected $failsafeTest = false;
+       
        /**
         * number of executed queries
         * @var integer
@@ -89,12 +95,13 @@ abstract class Database {
         * @param       string          $database               SQL database server database name
         * @param       integer         $port                   SQL database server port
         */
-       public function __construct($host, $user, $password, $database, $port) {
+       public function __construct($host, $user, $password, $database, $port, $failsafeTest = false) {
                $this->host = $host;
                $this->port = $port;
                $this->user = $user;
                $this->password = $password;
                $this->database = $database;
+               $this->failsafeTest = $failsafeTest;
                
                // connect database
                $this->connect();
index 5e4c9224a42490cb45b1b05436acba1f5e3ec221..73a3aebc5085449e128f618fd7b56b55a4ae1667 100644 (file)
@@ -24,9 +24,16 @@ class MySQLDatabase extends Database {
                if (!$this->port) $this->port = 3306; // mysql default port
                
                try {
-                       $this->pdo = new \PDO('mysql:host='.$this->host.';port='.$this->port.';dbname='.$this->database, $this->user, $this->password, array(
-                               \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
-                       ));
+                       $driverOptions = array(
+                               \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"
+                       );
+                       if (!$this->failsafeTest) {
+                               $driverOptions = array(
+                                       \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
+                               );
+                       }
+                       
+                       $this->pdo = new \PDO('mysql:host='.$this->host.';port='.$this->port.';dbname='.$this->database, $this->user, $this->password, $driverOptions);
                        $this->setAttributes();
                }
                catch (\PDOException $e) {