aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-03 09:24:34 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-03 09:24:34 +0200
commit001a7bad66fd1ce2b208abfe89177e72b5e1baa5 (patch)
treef95e1eb0520067393309eec0f6d7b6ddc2d89a90 /src
parent985f5f9d05f7ff7e443442b1775923b379c141d6 (diff)
downloadwallabag-001a7bad66fd1ce2b208abfe89177e72b5e1baa5.tar.gz
wallabag-001a7bad66fd1ce2b208abfe89177e72b5e1baa5.tar.zst
wallabag-001a7bad66fd1ce2b208abfe89177e72b5e1baa5.zip
Add a check for the database connection
Checking for the driver isn't enough. We are now checking if we can etablish a connection to the database before trying to do anything. By displaying the error from the Exception (in case of error) we hope to reduce issues overload about people getting error with the database
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index 813ac720..50d0dfff 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,21 @@ 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 $fulfilled = false;
100 $status = '<error>ERROR!</error>';
101 $help = 'Can\'t connect to the database: '.$e->getMessage();
102 }
103
88 $rows[] = [$label, $status, $help]; 104 $rows[] = [$label, $status, $help];
89 105
90 foreach ($this->functionExists as $functionRequired) { 106 foreach ($this->functionExists as $functionRequired) {