|
|
|
@ -82,8 +82,9 @@ class PostgreSQL extends AbstractDatabase { |
|
|
|
|
// the connection to dbname=postgres is not needed anymore |
|
|
|
|
$connection->close(); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
$this->logger->logException($e); |
|
|
|
|
$this->logger->warning('Error trying to connect as "postgres", assuming database is setup and tables need to be created'); |
|
|
|
|
$this->logger->warning('Error trying to connect as "postgres", assuming database is setup and tables need to be created', [ |
|
|
|
|
'exception' => $e, |
|
|
|
|
]); |
|
|
|
|
$this->config->setValues([ |
|
|
|
|
'dbuser' => $this->dbUser, |
|
|
|
|
'dbpassword' => $this->dbPassword, |
|
|
|
@ -97,7 +98,9 @@ class PostgreSQL extends AbstractDatabase { |
|
|
|
|
try { |
|
|
|
|
$connection->connect(); |
|
|
|
|
} catch (\Exception $e) { |
|
|
|
|
$this->logger->logException($e); |
|
|
|
|
$this->logger->error($e->getMessage(), [ |
|
|
|
|
'exception' => $e, |
|
|
|
|
]); |
|
|
|
|
throw new \OC\DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'), |
|
|
|
|
$this->trans->t('You need to enter details of an existing account.'), 0, $e); |
|
|
|
|
} |
|
|
|
@ -110,16 +113,18 @@ class PostgreSQL extends AbstractDatabase { |
|
|
|
|
try { |
|
|
|
|
$query->execute(); |
|
|
|
|
} catch (DatabaseException $e) { |
|
|
|
|
$this->logger->error('Error while trying to create database'); |
|
|
|
|
$this->logger->logException($e); |
|
|
|
|
$this->logger->error('Error while trying to create database', [ |
|
|
|
|
'exception' => $e, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE " . addslashes($this->dbName) . " FROM PUBLIC"); |
|
|
|
|
try { |
|
|
|
|
$query->execute(); |
|
|
|
|
} catch (DatabaseException $e) { |
|
|
|
|
$this->logger->error('Error while trying to restrict database permissions'); |
|
|
|
|
$this->logger->logException($e); |
|
|
|
|
$this->logger->error('Error while trying to restrict database permissions', [ |
|
|
|
|
'exception' => $e, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -161,8 +166,9 @@ class PostgreSQL extends AbstractDatabase { |
|
|
|
|
$query->execute(); |
|
|
|
|
} |
|
|
|
|
} catch (DatabaseException $e) { |
|
|
|
|
$this->logger->error('Error while trying to create database user'); |
|
|
|
|
$this->logger->logException($e); |
|
|
|
|
$this->logger->error('Error while trying to create database user', [ |
|
|
|
|
'exception' => $e, |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|