diff options
author | Joas Schilling <coding@schilljs.com> | 2022-02-02 15:03:11 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2022-02-07 14:34:10 +0000 |
commit | 016c6e38061a7c00b131405688bee8ea5c868779 (patch) | |
tree | 048c408523e4c3a5e64e7f54f0f4e670906fd59e /lib | |
parent | 1e2baa5a6bbcb23bfe25b49d03159ad4293d5280 (diff) | |
download | nextcloud-server-016c6e38061a7c00b131405688bee8ea5c868779.tar.gz nextcloud-server-016c6e38061a7c00b131405688bee8ea5c868779.zip |
Allow specify a config prefix for another database connection
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/DB/ConnectionFactory.php | 13 |
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; } |