From fc79f1ffa82529e5340d115b2f438ac5952e9cb0 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 22 Oct 2016 13:41:03 +0200 Subject: Add verification check for MySQL version Must now be >= 5.5.4 --- app/config/parameters.yml.dist | 4 ++-- app/config/tests/parameters_test.sqlite.yml | 2 +- src/Wallabag/CoreBundle/Command/InstallCommand.php | 18 +++++++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 436eeeda..7a22cb98 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -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 diff --git a/app/config/tests/parameters_test.sqlite.yml b/app/config/tests/parameters_test.sqlite.yml index 0efbe786..b8a5f41a 100644 --- a/app/config/tests/parameters_test.sqlite.yml +++ b/app/config/tests/parameters_test.sqlite.yml @@ -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 diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index 59110782..6f9aff60 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php @@ -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[] = [ + 'Database version', + 'ERROR!', + 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).' + ]; + } + } + foreach ($this->functionExists as $functionRequired) { $label = ''.$functionRequired.''; $status = 'OK!'; -- cgit v1.2.3