mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
fix(db): Don't use removed/deprecated methods in setup
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
c0d2f7ee21
commit
fb3d4d579f
2 changed files with 13 additions and 13 deletions
|
|
@ -66,7 +66,7 @@ class MySQL extends AbstractDatabase {
|
|||
//we can't use OC_DB functions here because we need to connect as the administrative user.
|
||||
$characterSet = $this->config->getValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
|
||||
$query = "CREATE DATABASE IF NOT EXISTS `$name` CHARACTER SET $characterSet COLLATE {$characterSet}_bin;";
|
||||
$connection->executeUpdate($query);
|
||||
$connection->executeStatement($query);
|
||||
} catch (\Exception $ex) {
|
||||
$this->logger->error('Database creation failed.', [
|
||||
'exception' => $ex,
|
||||
|
|
@ -78,7 +78,7 @@ class MySQL extends AbstractDatabase {
|
|||
try {
|
||||
//this query will fail if there aren't the right permissions, ignore the error
|
||||
$query = "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `$name` . * TO '$user'";
|
||||
$connection->executeUpdate($query);
|
||||
$connection->executeStatement($query);
|
||||
} catch (\Exception $ex) {
|
||||
$this->logger->debug('Could not automatically grant privileges, this can be ignored if database user already had privileges.', [
|
||||
'exception' => $ex,
|
||||
|
|
@ -100,14 +100,14 @@ class MySQL extends AbstractDatabase {
|
|||
|
||||
if ($connection->getDatabasePlatform() instanceof Mysql80Platform) {
|
||||
$query = "CREATE USER '$name'@'localhost' IDENTIFIED WITH mysql_native_password BY '$password'";
|
||||
$connection->executeUpdate($query);
|
||||
$connection->executeStatement($query);
|
||||
$query = "CREATE USER '$name'@'%' IDENTIFIED WITH mysql_native_password BY '$password'";
|
||||
$connection->executeUpdate($query);
|
||||
$connection->executeStatement($query);
|
||||
} else {
|
||||
$query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
|
||||
$connection->executeUpdate($query);
|
||||
$connection->executeStatement($query);
|
||||
$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
|
||||
$connection->executeUpdate($query);
|
||||
$connection->executeStatement($query);
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$this->logger->error('Database user creation failed.', [
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class PostgreSQL extends AbstractDatabase {
|
|||
->andWhere($builder->expr()->eq('rolname', $builder->createNamedParameter($this->dbUser)));
|
||||
|
||||
try {
|
||||
$result = $query->execute();
|
||||
$result = $query->executeQuery();
|
||||
$canCreateRoles = $result->rowCount() > 0;
|
||||
} catch (DatabaseException $e) {
|
||||
$canCreateRoles = false;
|
||||
|
|
@ -103,7 +103,7 @@ class PostgreSQL extends AbstractDatabase {
|
|||
//The database does not exists... let's create it
|
||||
$query = $connection->prepare("CREATE DATABASE " . addslashes($this->dbName) . " OWNER \"" . addslashes($this->dbUser) . '"');
|
||||
try {
|
||||
$query->execute();
|
||||
$query->executeStatement();
|
||||
} catch (DatabaseException $e) {
|
||||
$this->logger->error('Error while trying to create database', [
|
||||
'exception' => $e,
|
||||
|
|
@ -112,7 +112,7 @@ class PostgreSQL extends AbstractDatabase {
|
|||
} else {
|
||||
$query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE " . addslashes($this->dbName) . " FROM PUBLIC");
|
||||
try {
|
||||
$query->execute();
|
||||
$query->executeStatement();
|
||||
} catch (DatabaseException $e) {
|
||||
$this->logger->error('Error while trying to restrict database permissions', [
|
||||
'exception' => $e,
|
||||
|
|
@ -127,7 +127,7 @@ class PostgreSQL extends AbstractDatabase {
|
|||
$query = $builder->select('*')
|
||||
->from('pg_roles')
|
||||
->where($builder->expr()->eq('rolname', $builder->createNamedParameter($this->dbUser)));
|
||||
$result = $query->execute();
|
||||
$result = $query->executeQuery();
|
||||
return $result->rowCount() > 0;
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ class PostgreSQL extends AbstractDatabase {
|
|||
$query = $builder->select('datname')
|
||||
->from('pg_database')
|
||||
->where($builder->expr()->eq('datname', $builder->createNamedParameter($this->dbName)));
|
||||
$result = $query->execute();
|
||||
$result = $query->executeQuery();
|
||||
return $result->rowCount() > 0;
|
||||
}
|
||||
|
||||
|
|
@ -152,10 +152,10 @@ class PostgreSQL extends AbstractDatabase {
|
|||
|
||||
// create the user
|
||||
$query = $connection->prepare("CREATE USER \"" . addslashes($this->dbUser) . "\" CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
|
||||
$query->execute();
|
||||
$query->executeStatement();
|
||||
if ($this->databaseExists($connection)) {
|
||||
$query = $connection->prepare('GRANT CONNECT ON DATABASE ' . addslashes($this->dbName) . ' TO "' . addslashes($this->dbUser) . '"');
|
||||
$query->execute();
|
||||
$query->executeStatement();
|
||||
}
|
||||
} catch (DatabaseException $e) {
|
||||
$this->logger->error('Error while trying to create database user', [
|
||||
|
|
|
|||
Loading…
Reference in a new issue