]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix misleading MySQL DB creation error (#25485) 596/head
authorVincent Petry <pvince81@owncloud.com>
Tue, 26 Jul 2016 10:38:14 +0000 (12:38 +0200)
committerBjoern Schiessle <bjoern@schiessle.org>
Wed, 27 Jul 2016 09:45:13 +0000 (11:45 +0200)
Whenever the GRANT ALL failed, it used to display "Database creation
failed" which is incorrect. It's only the privleges setting that failed.

This moves the privilege setting message to DEBUG and makes it more
precise.

lib/private/Setup/MySQL.php

index 817a6060608ff5f53312bb453048a5123c8660d0..4ad6926c2d7c949a9133588b033b8231f77da937 100644 (file)
@@ -61,12 +61,20 @@ class MySQL extends AbstractDatabase {
                        //we can't use OC_BD functions here because we need to connect as the administrative user.
                        $query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET utf8 COLLATE utf8_bin;";
                        $connection->executeUpdate($query);
+               } catch (\Exception $ex) {
+                       $this->logger->error('Database creation failed: {error}', [
+                               'app' => 'mysql.setup',
+                               'error' => $ex->getMessage()
+                       ]);
+                       return;
+               }
 
+               try {
                        //this query will fail if there aren't the right permissions, ignore the error
                        $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'";
                        $connection->executeUpdate($query);
                } catch (\Exception $ex) {
-                       $this->logger->error('Database creation failed: {error}', [
+                       $this->logger->debug('Could not automatically grant privileges, this can be ignored if database user already had privileges: {error}', [
                                'app' => 'mysql.setup',
                                'error' => $ex->getMessage()
                        ]);