aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Setup/MySQL.php
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2021-01-08 14:58:43 +0100
committerGitHub <noreply@github.com>2021-01-08 14:58:43 +0100
commit81302f78e5cea60dc9064be8ed979d523ff84e18 (patch)
tree76e8d025c3003e718cf5e04105b782ba8aaa4891 /lib/private/Setup/MySQL.php
parentaeb32e1bc8f50d641e093589cc2f8c90da166768 (diff)
parent250f76a59cfc865e2a6bd36b690abeed3b529490 (diff)
downloadnextcloud-server-81302f78e5cea60dc9064be8ed979d523ff84e18.tar.gz
nextcloud-server-81302f78e5cea60dc9064be8ed979d523ff84e18.zip
Merge pull request #24948 from nextcloud/dependabot/composer/doctrine/dbal-3.0.0
Bump doctrine/dbal from 2.12.0 to 3.0.0
Diffstat (limited to 'lib/private/Setup/MySQL.php')
-rw-r--r--lib/private/Setup/MySQL.php42
1 files changed, 20 insertions, 22 deletions
diff --git a/lib/private/Setup/MySQL.php b/lib/private/Setup/MySQL.php
index 966c97edf55..21339dc46d0 100644
--- a/lib/private/Setup/MySQL.php
+++ b/lib/private/Setup/MySQL.php
@@ -31,6 +31,7 @@
namespace OC\Setup;
+use OC\DB\ConnectionAdapter;
use OC\DB\MySqlTools;
use OCP\IDBConnection;
use OCP\ILogger;
@@ -45,12 +46,12 @@ class MySQL extends AbstractDatabase {
// detect mb4
$tools = new MySqlTools();
- if ($tools->supports4ByteCharset($connection)) {
+ if ($tools->supports4ByteCharset(new ConnectionAdapter($connection))) {
$this->config->setValue('mysql.utf8mb4', true);
$connection = $this->connect(['dbname' => null]);
}
- $this->createSpecificUser($username, $connection);
+ $this->createSpecificUser($username, new ConnectionAdapter($connection));
//create the database
$this->createDatabase($connection);
@@ -156,27 +157,24 @@ class MySQL extends AbstractDatabase {
$result = $connection->executeQuery($query, [$adminUser]);
//current dbuser has admin rights
- if ($result) {
- $data = $result->fetchAll();
- //new dbuser does not exist
- if (count($data) === 0) {
- //use the admin login data for the new database user
- $this->dbUser = $adminUser;
-
- //create a random password so we don't need to store the admin password in the config file
- $this->dbPassword = $this->random->generate(30);
-
- $this->createDBUser($connection);
-
- break;
- } else {
- //repeat with different username
- $length = strlen((string)$i);
- $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i;
- $i++;
- }
- } else {
+ $data = $result->fetchAll();
+ $result->closeCursor();
+ //new dbuser does not exist
+ if (count($data) === 0) {
+ //use the admin login data for the new database user
+ $this->dbUser = $adminUser;
+
+ //create a random password so we don't need to store the admin password in the config file
+ $this->dbPassword = $this->random->generate(30);
+
+ $this->createDBUser($connection);
+
break;
+ } else {
+ //repeat with different username
+ $length = strlen((string)$i);
+ $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i;
+ $i++;
}
}
}