]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Force server version to avoid connexion error 1903/head
authorJeremy Benoist <jeremy.benoist@gmail.com>
Sun, 10 Apr 2016 13:34:32 +0000 (15:34 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sun, 10 Apr 2016 13:34:32 +0000 (15:34 +0200)
When installing a new project with MySQL, if the database doesn't exist before installation will fail because DBAL will try to get the server version by querying it.
And since this query is done using the default database connexion and since the database doesn't exist, DBAL can't connect to the server.

app/config/config.yml
src/Wallabag/CoreBundle/Command/InstallCommand.php

index a876669407caf66826d9b54974b25669682d6342..8618845516813fb3fc3e2f583595b68d972729a9 100644 (file)
@@ -82,6 +82,7 @@ doctrine:
         password: "%database_password%"
         charset:  UTF8
         path:     "%database_path%"
+        server_version: 5.6
 
     orm:
         auto_generate_proxy_classes: "%kernel.debug%"
index c5a5a519ceb3dd5f0df69d1a98eaeacad6a20778..2e4a59dfdb92910d32e7d360eb837b493cc41584 100644 (file)
@@ -455,7 +455,13 @@ class InstallCommand extends ContainerAwareCommand
             return false;
         }
 
-        return in_array($databaseName, $schemaManager->listDatabases());
+        try {
+            return in_array($databaseName, $schemaManager->listDatabases());
+        } catch (\Doctrine\DBAL\Exception\ConnectionException $e) {
+            // it means we weren't able to get database list, assume the database doesn't exist
+
+            return false;
+        }
     }
 
     /**