diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-22 13:41:03 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-22 13:41:03 +0200 |
commit | fc79f1ffa82529e5340d115b2f438ac5952e9cb0 (patch) | |
tree | 5ea1a45b1b418e27c71cc4fe59b7533d7e1bdfd2 /src | |
parent | b0de88f75dead50385e80e3897dc3913a971b91e (diff) | |
download | wallabag-fc79f1ffa82529e5340d115b2f438ac5952e9cb0.tar.gz wallabag-fc79f1ffa82529e5340d115b2f438ac5952e9cb0.tar.zst wallabag-fc79f1ffa82529e5340d115b2f438ac5952e9cb0.zip |
Add verification check for MySQL version
Must now be >= 5.5.4
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/InstallCommand.php | 18 |
1 files changed, 17 insertions, 1 deletions
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>'; |