aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-09-03 13:34:13 +0200
committerGitHub <noreply@github.com>2016-09-03 13:34:13 +0200
commit2b9c5097d438c5493e5c47c7084fc01d1eb19686 (patch)
treecf83462799bcdf542b4debc0ff51736c43711ad3 /src/Wallabag
parent985f5f9d05f7ff7e443442b1775923b379c141d6 (diff)
parent5070644a12ad264444a812b783a04386d6581cb0 (diff)
downloadwallabag-2b9c5097d438c5493e5c47c7084fc01d1eb19686.tar.gz
wallabag-2b9c5097d438c5493e5c47c7084fc01d1eb19686.tar.zst
wallabag-2b9c5097d438c5493e5c47c7084fc01d1eb19686.zip
Merge pull request #2262 from wallabag/install-check-db-connection
Add a check for the database connection
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 813ac720..035eb865 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -72,8 +72,10 @@ class InstallCommand extends ContainerAwareCommand
72 { 72 {
73 $this->defaultOutput->writeln('<info><comment>Step 1 of 5.</comment> Checking system requirements.</info>'); 73 $this->defaultOutput->writeln('<info><comment>Step 1 of 5.</comment> Checking system requirements.</info>');
74 74
75 $fulfilled = true; 75 $rows = [];
76 76
77 // testing if database driver exists
78 $fulfilled = true;
77 $label = '<comment>PDO Driver</comment>'; 79 $label = '<comment>PDO Driver</comment>';
78 $status = '<info>OK!</info>'; 80 $status = '<info>OK!</info>';
79 $help = ''; 81 $help = '';
@@ -84,7 +86,23 @@ class InstallCommand extends ContainerAwareCommand
84 $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.'; 86 $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.';
85 } 87 }
86 88
87 $rows = []; 89 $rows[] = [$label, $status, $help];
90
91 // testing if connection to the database can be etablished
92 $label = '<comment>Database connection</comment>';
93 $status = '<info>OK!</info>';
94 $help = '';
95
96 try {
97 $this->getContainer()->get('doctrine')->getManager()->getConnection()->connect();
98 } catch (\Exception $e) {
99 if (false === strpos($e->getMessage(), 'Unknown database')) {
100 $fulfilled = false;
101 $status = '<error>ERROR!</error>';
102 $help = 'Can\'t connect to the database: '.$e->getMessage();
103 }
104 }
105
88 $rows[] = [$label, $status, $help]; 106 $rows[] = [$label, $status, $help];
89 107
90 foreach ($this->functionExists as $functionRequired) { 108 foreach ($this->functionExists as $functionRequired) {
@@ -456,7 +474,7 @@ class InstallCommand extends ContainerAwareCommand
456 } 474 }
457 475
458 // custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite 476 // custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite
459 if ('sqlite' == $schemaManager->getDatabasePlatform()->getName()) { 477 if ('sqlite' === $schemaManager->getDatabasePlatform()->getName()) {
460 $params = $this->getContainer()->get('doctrine.dbal.default_connection')->getParams(); 478 $params = $this->getContainer()->get('doctrine.dbal.default_connection')->getParams();
461 479
462 if (isset($params['path']) && file_exists($params['path'])) { 480 if (isset($params['path']) && file_exists($params['path'])) {