diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/InstallCommand.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/InstallCommand.php | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php index c7e714af..e95c3a7b 100644 --- a/src/Wallabag/CoreBundle/Command/InstallCommand.php +++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php | |||
@@ -72,6 +72,7 @@ class InstallCommand extends ContainerAwareCommand | |||
72 | protected function checkRequirements() | 72 | protected function checkRequirements() |
73 | { | 73 | { |
74 | $this->defaultOutput->writeln('<info><comment>Step 1 of 4.</comment> Checking system requirements.</info>'); | 74 | $this->defaultOutput->writeln('<info><comment>Step 1 of 4.</comment> Checking system requirements.</info>'); |
75 | $doctrineManager = $this->getContainer()->get('doctrine')->getManager(); | ||
75 | 76 | ||
76 | $rows = []; | 77 | $rows = []; |
77 | 78 | ||
@@ -108,21 +109,39 @@ class InstallCommand extends ContainerAwareCommand | |||
108 | 109 | ||
109 | $rows[] = [$label, $status, $help]; | 110 | $rows[] = [$label, $status, $help]; |
110 | 111 | ||
112 | // check MySQL & PostgreSQL version | ||
113 | $label = '<comment>Database version</comment>'; | ||
114 | $status = '<info>OK!</info>'; | ||
115 | $help = ''; | ||
116 | |||
111 | // now check if MySQL isn't too old to handle utf8mb4 | 117 | // now check if MySQL isn't too old to handle utf8mb4 |
112 | if ($conn->isConnected() && $conn->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) { | 118 | if ($conn->isConnected() && 'mysql' === $conn->getDatabasePlatform()->getName()) { |
113 | $version = $conn->query('select version()')->fetchColumn(); | 119 | $version = $conn->query('select version()')->fetchColumn(); |
114 | $minimalVersion = '5.5.4'; | 120 | $minimalVersion = '5.5.4'; |
115 | 121 | ||
116 | if (false === version_compare($version, $minimalVersion, '>')) { | 122 | if (false === version_compare($version, $minimalVersion, '>')) { |
117 | $fulfilled = false; | 123 | $fulfilled = false; |
118 | $rows[] = [ | 124 | $status = '<error>ERROR!</error>'; |
119 | '<comment>Database version</comment>', | 125 | $help = 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).'; |
120 | '<error>ERROR!</error>', | ||
121 | 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).', | ||
122 | ]; | ||
123 | } | 126 | } |
124 | } | 127 | } |
125 | 128 | ||
129 | // testing if PostgreSQL > 9.1 | ||
130 | if ($conn->isConnected() && 'postgresql' === $conn->getDatabasePlatform()->getName()) { | ||
131 | // return version should be like "PostgreSQL 9.5.4 on x86_64-apple-darwin15.6.0, compiled by Apple LLVM version 8.0.0 (clang-800.0.38), 64-bit" | ||
132 | $version = $doctrineManager->getConnection()->query('SELECT version();')->fetchColumn(); | ||
133 | |||
134 | preg_match('/PostgreSQL ([0-9\.]+)/i', $version, $matches); | ||
135 | |||
136 | if (isset($matches[1]) & version_compare($matches[1], '9.2.0', '<')) { | ||
137 | $fulfilled = false; | ||
138 | $status = '<error>ERROR!</error>'; | ||
139 | $help = 'PostgreSQL should be greater than 9.1 (actual version: '.$matches[1].')'; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | $rows[] = [$label, $status, $help]; | ||
144 | |||
126 | foreach ($this->functionExists as $functionRequired) { | 145 | foreach ($this->functionExists as $functionRequired) { |
127 | $label = '<comment>'.$functionRequired.'</comment>'; | 146 | $label = '<comment>'.$functionRequired.'</comment>'; |
128 | $status = '<info>OK!</info>'; | 147 | $status = '<info>OK!</info>'; |