Merge pull request #3643 from Icinga/feature/db-oracle-hostname-optional

DbConnection: Make host optional for Oracle connections
This commit is contained in:
Markus Frosch 2018-12-05 15:09:46 +01:00 committed by GitHub
commit a95e645236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -58,6 +58,12 @@ class DbResourceForm extends Form
$offerMysql = true;
}
if ($dbChoice === 'oracle') {
$hostIsRequired = false;
} else {
$hostIsRequired = true;
}
$socketInfo = '';
if ($offerPostgres) {
$socketInfo = $this->translate(
@ -104,7 +110,7 @@ class DbResourceForm extends Form
'text',
'host',
array (
'required' => true,
'required' => $hostIsRequired,
'label' => $this->translate('Host'),
'description' => $this->translate('The hostname of the database')
. ($socketInfo ? '. ' . $socketInfo : ''),

View File

@ -215,6 +215,11 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
case 'oracle':
$adapter = 'Pdo_Oci';
$defaultPort = 1521;
// remove host parameter when not configured
if (empty($this->config->host)) {
unset($adapterParamaters['host']);
}
break;
case 'pgsql':
$adapter = 'Pdo_Pgsql';
@ -555,7 +560,7 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
'Connection to %s as %s on %s:%s successful',
$config['dbname'],
$config['username'],
$config['host'],
array_key_exists('host', $config) ? $config['host'] : '(none)',
$config['port']
));
switch ($this->dbType) {