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:
authorJoas Schilling <coding@schilljs.com>2022-02-02 17:03:11 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2022-02-07 17:35:54 +0300
commit5e8dd12926c71ae96e6967d632002f8f0576d206 (patch)
tree17d34ac4a0b7e70ccf21030c812581f065a54b83
parenta0b80da3787aa962716eb37836d9c13c7b2b2fd0 (diff)
Allow specify a config prefix for another database connection
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/DB/ConnectionFactory.php13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php
index b4c7597f6d4..a1fe40dc13f 100644
--- a/lib/private/DB/ConnectionFactory.php
+++ b/lib/private/DB/ConnectionFactory.php
@@ -189,22 +189,23 @@ class ConnectionFactory {
/**
* Create the connection parameters for the config
*
+ * @param string $configPrefix
* @return array
*/
- public function createConnectionParams() {
+ public function createConnectionParams(string $configPrefix = '') {
$type = $this->config->getValue('dbtype', 'sqlite');
$connectionParams = [
- 'user' => $this->config->getValue('dbuser', ''),
- 'password' => $this->config->getValue('dbpassword', ''),
+ 'user' => $this->config->getValue($configPrefix . 'dbuser', $this->config->getValue('dbuser', '')),
+ 'password' => $this->config->getValue($configPrefix . 'dbpassword', $this->config->getValue('dbpassword', '')),
];
- $name = $this->config->getValue('dbname', self::DEFAULT_DBNAME);
+ $name = $this->config->getValue($configPrefix . 'dbname', $this->config->getValue('dbname', self::DEFAULT_DBNAME));
if ($this->normalizeType($type) === 'sqlite3') {
$dataDir = $this->config->getValue("datadirectory", \OC::$SERVERROOT . '/data');
$connectionParams['path'] = $dataDir . '/' . $name . '.db';
} else {
- $host = $this->config->getValue('dbhost', '');
+ $host = $this->config->getValue($configPrefix . 'dbhost', $this->config->getValue('dbhost', ''));
$connectionParams = array_merge($connectionParams, $this->splitHostFromPortAndSocket($host));
$connectionParams['dbname'] = $name;
}
@@ -213,7 +214,7 @@ class ConnectionFactory {
$connectionParams['sqlite.journal_mode'] = $this->config->getValue('sqlite.journal_mode', 'WAL');
//additional driver options, eg. for mysql ssl
- $driverOptions = $this->config->getValue('dbdriveroptions', null);
+ $driverOptions = $this->config->getValue($configPrefix . 'dbdriveroptions', $this->config->getValue('dbdriveroptions', null));
if ($driverOptions) {
$connectionParams['driverOptions'] = $driverOptions;
}