aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2015-04-08 16:55:07 +0200
committerThomas Citharel <tcit@tcit.fr>2015-04-08 16:55:07 +0200
commitfdda9fd9a356b38aad39a4f3703085ce8afc161b (patch)
treec9445eff79bb34387cabbb41db02cd63d63630ee
parent6f136f4df2f8f5daeca2878e61015ee7fa162bb7 (diff)
downloadwallabag-1.9.1beta1.tar.gz
wallabag-1.9.1beta1.tar.zst
wallabag-1.9.1beta1.zip
fix installation error on wrong credentials (#1175 and #1114)1.9.1beta1
-rwxr-xr-xinstall/index.php43
1 files changed, 35 insertions, 8 deletions
diff --git a/install/index.php b/install/index.php
index fc16af0c..77e50864 100755
--- a/install/index.php
+++ b/install/index.php
@@ -144,16 +144,43 @@ else if (isset($_POST['install'])) {
144 $sql_structure = file_get_contents('install/postgres.sql'); 144 $sql_structure = file_get_contents('install/postgres.sql');
145 } 145 }
146 // create database structure 146 // create database structure
147 $query = $handle->exec($sql_structure); 147 if (!$handle) {
148 148 $continue = false;
149 $usertest = executeQuery($handle,"SELECT * from users WHERE username = ?", array($username)); 149 $errors[] = "Couldn't connect to your database server. Please check credentials.";
150 if (!empty($usertest)) { 150 } else {
151 $continue = false; 151 $query = $handle->exec($sql_structure);
152 $errors[] = "An user already exists with this username in database."; 152
153 } 153 $usertest = executeQuery($handle,"SELECT * from users WHERE username = ?", array($username));
154 if (!empty($usertest)) {
155 $continue = false;
156 $errors[] = "An user already exists with this username in database.";
157 }
158 }
154 159
155 } catch (PDOException $e) { 160 } catch (PDOException $e) {
156 $errors[] = $e->getMessage(); 161 /* Error codes :
162 / 7 : PostgreSQL issues
163 / 1045 : Access denied to the user : user doesn't exists
164 / 1044 : Access denied to the user : user doesn't have the rights to connect to this database
165 / 2005 : Unknown database server
166 */
167 switch ($e->getCode()) {
168 case 7:
169 $errors[] = "PostgreSQL has encountered an issue : " . $e->getMessage();
170 break;
171 case 1045:
172 $errors[] = "The password for this user is incorrect, or this user doesn't exist.";
173 break;
174 case 1044:
175 $errors[] = "The user isn't allowed to use this database.";
176 break;
177 case 2005:
178 $errors[] = "The server can't be reached.";
179 break;
180 default:
181 $errors[] = "A error happened while connecting to your database : " . $e->getMessage();
182 break;
183 }
157 $continue = false; 184 $continue = false;
158 } 185 }
159 } 186 }