Skip to content

Commit

Permalink
Always merge control user configuration
Browse files Browse the repository at this point in the history
Issue #12218

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Jul 29, 2016
1 parent 9d0c745 commit 4054228
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions libraries/DatabaseInterface.php
Expand Up @@ -2244,36 +2244,33 @@ public function getConnectionParams($mode, $server = null)
$password = $cfg['Server']['controlpass'];

$server = array();
if (! empty($cfg['Server']['controlhost'])
|| ! empty($cfg['Server']['controlport'])
) {
if (! empty($cfg['Server']['controlhost'])) {
$server['host'] = $cfg['Server']['controlhost'];
} else {
$server['host'] = $cfg['Server']['host'];
}
// Share the settings if the host is same
if ($server['host'] == $cfg['Server']['host']) {
$shared = array(
'port', 'socket', 'connect_type', 'compress',
'ssl', 'ssl_key', 'ssl_cert', 'ssl_ca',
'ssl_ca_path', 'ssl_ciphers', 'ssl_verify',
);
foreach ($shared as $item) {
if (isset($cfg['Server'][$item])) {
$server[$item] = $cfg['Server'][$item];
}

if (! empty($cfg['Server']['controlhost'])) {
$server['host'] = $cfg['Server']['controlhost'];
} else {
$server['host'] = $cfg['Server']['host'];
}
// Share the settings if the host is same
if ($server['host'] == $cfg['Server']['host']) {
$shared = array(
'port', 'socket', 'connect_type', 'compress',
'ssl', 'ssl_key', 'ssl_cert', 'ssl_ca',
'ssl_ca_path', 'ssl_ciphers', 'ssl_verify',
);
foreach ($shared as $item) {
if (isset($cfg['Server'][$item])) {
$server[$item] = $cfg['Server'][$item];
}
}
// Set configured port
if (! empty($cfg['Server']['controlport'])) {
$server['port'] = $cfg['Server']['controlport'];
}
// Set any configuration with control_ prefix
foreach ($cfg['Server'] as $key => $val) {
if (substr($key, 0, 8) === 'control_') {
$server[substr($key, 8)] = $val;
}
}
// Set configured port
if (! empty($cfg['Server']['controlport'])) {
$server['port'] = $cfg['Server']['controlport'];
}
// Set any configuration with control_ prefix
foreach ($cfg['Server'] as $key => $val) {
if (substr($key, 0, 8) === 'control_') {
$server[substr($key, 8)] = $val;
}
}
} else {
Expand Down

0 comments on commit 4054228

Please sign in to comment.