aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-22 13:41:03 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-22 13:41:03 +0200
commitfc79f1ffa82529e5340d115b2f438ac5952e9cb0 (patch)
tree5ea1a45b1b418e27c71cc4fe59b7533d7e1bdfd2
parentb0de88f75dead50385e80e3897dc3913a971b91e (diff)
downloadwallabag-fc79f1ffa82529e5340d115b2f438ac5952e9cb0.tar.gz
wallabag-fc79f1ffa82529e5340d115b2f438ac5952e9cb0.tar.zst
wallabag-fc79f1ffa82529e5340d115b2f438ac5952e9cb0.zip
Add verification check for MySQL version
Must now be >= 5.5.4
-rw-r--r--app/config/parameters.yml.dist4
-rw-r--r--app/config/tests/parameters_test.sqlite.yml2
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php18
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:
19 database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite" 19 database_path: "%kernel.root_dir%/../data/db/wallabag.sqlite"
20 database_table_prefix: wallabag_ 20 database_table_prefix: wallabag_
21 database_socket: null 21 database_socket: null
22 # with MySQL, use "utf8mb4" if got problem with content with emojis 22 # with MySQL, use "utf8mb4" if you got problem with content with emojis
23 database_charset: utf8mb4 23 database_charset: utf8
24 24
25 mailer_transport: smtp 25 mailer_transport: smtp
26 mailer_host: 127.0.0.1 26 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:
6 test_database_user: ~ 6 test_database_user: ~
7 test_database_password: ~ 7 test_database_password: ~
8 test_database_path: "%kernel.root_dir%/../data/db/wallabag_test.sqlite" 8 test_database_path: "%kernel.root_dir%/../data/db/wallabag_test.sqlite"
9 test_database_charset: utf8mb4 9 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
95 $help = ''; 95 $help = '';
96 96
97 try { 97 try {
98 $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); 98 $conn = $this->getContainer()->get('doctrine')->getManager()->getConnection();
99 $conn->connect();
99 } catch (\Exception $e) { 100 } catch (\Exception $e) {
100 if (false === strpos($e->getMessage(), 'Unknown database') 101 if (false === strpos($e->getMessage(), 'Unknown database')
101 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) { 102 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) {
@@ -107,6 +108,21 @@ class InstallCommand extends ContainerAwareCommand
107 108
108 $rows[] = [$label, $status, $help]; 109 $rows[] = [$label, $status, $help];
109 110
111 // now check if MySQL isn't too old to handle utf8mb4
112 if ($conn->isConnected() && $conn->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
113 $version = $conn->query('select version()')->fetchColumn();
114 $minimalVersion = '5.5.4';
115
116 if (false === version_compare($version, $minimalVersion, '>')) {
117 $fulfilled = false;
118 $rows[] = [
119 '<comment>Database version</comment>',
120 '<error>ERROR!</error>',
121 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).'
122 ];
123 }
124 }
125
110 foreach ($this->functionExists as $functionRequired) { 126 foreach ($this->functionExists as $functionRequired) {
111 $label = '<comment>'.$functionRequired.'</comment>'; 127 $label = '<comment>'.$functionRequired.'</comment>';
112 $status = '<info>OK!</info>'; 128 $status = '<info>OK!</info>';