]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Check DB connection before any possible use
authorSandro Santilli <strk@kbt.io>
Tue, 24 May 2016 14:49:50 +0000 (16:49 +0200)
committerSandro Santilli <strk@kbt.io>
Tue, 24 May 2016 14:49:50 +0000 (16:49 +0200)
lib/installer.php

index d2fda9256094a0dfff2b2e2454a71511a3add094..346c706d61aab1fd4fe8a05363c4edd72e8c64be 100644 (file)
@@ -285,6 +285,11 @@ abstract class Installer
         $this->updateStatus("Checking database...");
         $conn = $this->connectDatabase($dsn);
 
+        if (!$conn instanceof DB_common) {
+            // Is not the right instance
+            throw new Exception('Cannot connect to database: ' . $conn->getMessage());
+        }
+
         // ensure database encoding is UTF8
         if ($this->dbtype == 'mysql') {
             // @fixme utf8m4 support for mysql 5.5?
@@ -299,11 +304,6 @@ abstract class Installer
             }
         }
 
-        if (!$conn instanceof DB_common) {
-            // Is not the right instance
-            throw new Exception('Cannot connect to database: ' . $conn->getMessage());
-        }
-
         $res = $this->updateStatus("Creating database tables...");
         if (!$this->createCoreTables($conn)) {
             $this->updateStatus("Error creating tables.", true);