]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add verification check for MySQL version
authorJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 22 Oct 2016 11:41:03 +0000 (13:41 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 22 Oct 2016 11:41:03 +0000 (13:41 +0200)
Must now be >= 5.5.4

app/config/parameters.yml.dist
app/config/tests/parameters_test.sqlite.yml
src/Wallabag/CoreBundle/Command/InstallCommand.php

index 436eeeda36ff473371eb24e2fa0a6b6ca9078fa7..7a22cb9870fbe10faf13ff69062fca37a597ee61 100644 (file)
@@ -19,8 +19,8 @@ parameters:
     database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
     database_table_prefix: wallabag_
     database_socket: null
-    # with MySQL, use "utf8mb4" if got problem with content with emojis
-    database_charset: utf8mb4
+    # with MySQL, use "utf8mb4" if you got problem with content with emojis
+    database_charset: utf8
 
     mailer_transport: smtp
     mailer_host: 127.0.0.1
index 0efbe78622d00ec65c936de2776cdaf976c8f6c8..b8a5f41a709020ae1e59a3d47f15dd10f47732a5 100644 (file)
@@ -6,4 +6,4 @@ parameters:
     test_database_user: ~
     test_database_password: ~
     test_database_path: "%kernel.root_dir%/../data/db/wallabag_test.sqlite"
-    test_database_charset: utf8mb4
+    test_database_charset: utf8
index 591107821c854345f8e133fbb6d219f19b27fffa..6f9aff60ae3e860ac409b99d6101e0763c304f39 100644 (file)
@@ -95,7 +95,8 @@ class InstallCommand extends ContainerAwareCommand
         $help = '';
 
         try {
-            $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect();
+            $conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
+            $conn->connect();
         } catch (\Exception $e) {
             if (false === strpos($e->getMessage(), 'Unknown database')
                 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) {
@@ -107,6 +108,21 @@ class InstallCommand extends ContainerAwareCommand
 
         $rows[] = [$label, $status, $help];
 
+        // now check if MySQL isn't too old to handle utf8mb4
+        if ($conn->isConnected() && $conn->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
+            $version = $conn->query('select version()')->fetchColumn();
+            $minimalVersion = '5.5.4';
+
+            if (false === version_compare($version, $minimalVersion, '>')) {
+                $fulfilled = false;
+                $rows[] = [
+                    '<comment>Database version</comment>',
+                    '<error>ERROR!</error>',
+                    'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).'
+                ];
+            }
+        }
+
         foreach ($this->functionExists as $functionRequired) {
             $label = '<comment>'.$functionRequired.'</comment>';
             $status = '<info>OK!</info>';