From 06c6b09863ec249c781c40608bb57554e5193c38 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 17 Sep 2015 12:46:49 +0200 Subject: [PATCH] Set default port for Postgres connections if it's the first available driver refs #9683 --- .../forms/Config/Resource/DbResourceForm.php | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/application/forms/Config/Resource/DbResourceForm.php b/application/forms/Config/Resource/DbResourceForm.php index bf1617c97..d79ad248b 100644 --- a/application/forms/Config/Resource/DbResourceForm.php +++ b/application/forms/Config/Resource/DbResourceForm.php @@ -30,20 +30,26 @@ class DbResourceForm extends Form if (Platform::hasMysqlSupport()) { $dbChoices['mysql'] = 'MySQL'; } + if (Platform::hasPostgresqlSupport()) { + $dbChoices['pgsql'] = 'PostgreSQL'; + } if (Platform::hasMssqlSupport()) { $dbChoices['mssql'] = 'MSSQL'; } - if (Platform::hasOciSupport()) { - $dbChoices['oci'] = 'Oracle (OCI8)'; - } if (Platform::hasOracleSupport()) { $dbChoices['oracle'] = 'Oracle'; } - if (Platform::hasPostgresqlSupport()) { - $dbChoices['pgsql'] = 'PostgreSQL'; + if (Platform::hasOciSupport()) { + $dbChoices['oci'] = 'Oracle (OCI8)'; + } + $offerPostgres = false; + if (isset($formData['db'])) { + if ($formData['db'] === 'pgsql') { + $offerPostgres = true; + } + } elseif (key($dbChoices) === 'pgsql') { + $offerPostgres = true; } - - $this->addElement( 'text', 'name', @@ -81,8 +87,8 @@ class DbResourceForm extends Form 'description' => $this->translate('The port to use'), 'label' => $this->translate('Port'), 'preserveDefault' => true, - 'required' => isset($formData['db']) && $formData['db'] === 'pgsql', - 'value' => isset($formData['db']) && $formData['db'] === 'pgsql' ? 5432 : null + 'required' => $offerPostgres, + 'value' => $offerPostgres ? 5432 : null ) ); $this->addElement(