aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2016-11-19 12:00:18 +0100
committerGitHub <noreply@github.com>2016-11-19 12:00:18 +0100
commit4c27f14fa94d300194a37a06355a109aae4afbf6 (patch)
tree4eaf4a6f9107ffd1e79970b7fa2df72f41370497
parenteabcd880ca543d0d6ac7f994c6f8ecddb557ab54 (diff)
parentcffcce0c921ca9360daa96e90bbf3e34642b262e (diff)
downloadwallabag-4c27f14fa94d300194a37a06355a109aae4afbf6.tar.gz
wallabag-4c27f14fa94d300194a37a06355a109aae4afbf6.tar.zst
wallabag-4c27f14fa94d300194a37a06355a109aae4afbf6.zip
Merge pull request #2604 from wallabag/postgresql-version
wallabag can’t work on PostgreSQL <= 9.1
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 857a8b4c..2daf2dd8 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
@@ -95,7 +96,7 @@ class InstallCommand extends ContainerAwareCommand
95 $help = ''; 96 $help = '';
96 97
97 try { 98 try {
98 $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect(); 99 $doctrineManager->getConnection()->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,26 @@ class InstallCommand extends ContainerAwareCommand
107 108
108 $rows[] = [$label, $status, $help]; 109 $rows[] = [$label, $status, $help];
109 110
111 // testing if PostgreSQL > 9.1
112 $label = '<comment>SGBD version</comment>';
113 $status = '<info>OK!</info>';
114 $help = '';
115
116 if ('postgresql' === $doctrineManager->getConnection()->getSchemaManager()->getDatabasePlatform()->getName()) {
117 // 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"
118 $version = $doctrineManager->getConnection()->query('SELECT version();')->fetchColumn();
119
120 preg_match('/PostgreSQL ([0-9\.]+)/i', $version, $matches);
121
122 if (isset($matches[1]) & version_compare($matches[1], '9.2.0', '<')) {
123 $fulfilled = false;
124 $status = '<error>ERROR!</error>';
125 $help = 'PostgreSQL should be greater than 9.1 (actual version: '.$matches[1].')';
126 }
127 }
128
129 $rows[] = [$label, $status, $help];
130
110 foreach ($this->functionExists as $functionRequired) { 131 foreach ($this->functionExists as $functionRequired) {
111 $label = '<comment>'.$functionRequired.'</comment>'; 132 $label = '<comment>'.$functionRequired.'</comment>';
112 $status = '<info>OK!</info>'; 133 $status = '<info>OK!</info>';