Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Comeau <sean@ftlnetworks.ca>2013-01-11 02:43:08 +0400
committerSean Comeau <sean@ftlnetworks.ca>2013-01-11 02:43:08 +0400
commitba9c967435ce62bb418c5c67eeb22184b009b24f (patch)
tree4fe48ace31ac1b85382b077bc30f93784cd5d32e /lib/setup.php
parent23dd7f1beaf9b567c1f3ec1438858cffc304dc13 (diff)
Throw an exception when creating a MySQL user fails and display exception error text to user
Diffstat (limited to 'lib/setup.php')
-rw-r--r--lib/setup.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/setup.php b/lib/setup.php
index fdd10be6824..9fa6aaf10b8 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -70,9 +70,10 @@ class OC_Setup {
try {
self::setupMySQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username);
} catch (Exception $e) {
+ $msgs = explode('|', $e->getMessage());
$error[] = array(
- 'error' => 'MySQL username and/or password not valid',
- 'hint' => 'You need to enter either an existing account or the administrator.'
+ 'error' => $msgs[0],
+ 'hint' => $msgs[1]
);
return($error);
}
@@ -166,7 +167,7 @@ class OC_Setup {
//check if the database user has admin right
$connection = @mysql_connect($dbhost, $dbuser, $dbpass);
if(!$connection) {
- throw new Exception('MySQL username and/or password not valid');
+ throw new Exception('MySQL username and/or password not valid|You need to enter either an existing account or the administrator.');
}
$oldUser=OC_Config::getValue('dbuser', false);
@@ -229,8 +230,14 @@ class OC_Setup {
// the anonymous user would take precedence when there is one.
$query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
$result = mysql_query($query, $connection);
+ if (!$result) {
+ throw new Exception("MySQL user '" . "$name" . "'@'localhost' already exists|Delete this user from MySQL.");
+ }
$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
$result = mysql_query($query, $connection);
+ if (!$result) {
+ throw new Exception("MySQL user '" . "$name" . "'@'%' already exists|Delete this user from MySQL.");
+ }
}
private static function setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username) {