Make db requirement checks more sensitive

fixes #7837
This commit is contained in:
Johannes Meyer 2014-12-01 15:38:10 +01:00
parent 2b14dbaff3
commit ebf908b1b5
6 changed files with 30 additions and 6 deletions

View File

@ -29,10 +29,10 @@ class DbResourceForm extends Form
public function createElements(array $formData)
{
$dbChoices = array();
if (Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql')) {
if (Platform::hasMysqlSupport()) {
$dbChoices['mysql'] = 'MySQL';
}
if (Platform::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql')) {
if (Platform::hasPostgresqlSupport()) {
$dbChoices['pgsql'] = 'PostgreSQL';
}

View File

@ -217,7 +217,7 @@ class ResourceConfigForm extends ConfigForm
if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) {
$resourceTypes['ldap'] = 'LDAP';
}
if ($resourceType === 'db' || Platform::extensionLoaded('mysql') || Platform::extensionLoaded('pgsql')) {
if ($resourceType === 'db' || Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
$resourceTypes['db'] = t('SQL Database');
}

View File

@ -197,4 +197,28 @@ class Platform
return (@include str_replace('_', '/', $name) . '.php') !== false;
}
/**
* Return whether it's possible to connect to a MySQL database
*
* Checks whether the mysql pdo extension has been loaded and the Zend framework adapter for MySQL is available
*
* @return bool
*/
public static function hasMysqlSupport()
{
return static::extensionLoaded('mysql') && static::zendClassExists('Zend_Db_Adapter_Pdo_Mysql');
}
/**
* Return whether it's possible to connect to a PostgreSQL database
*
* Checks whether the pgsql pdo extension has been loaded and the Zend framework adapter for PostgreSQL is available
*
* @return bool
*/
public static function hasPostgresqlSupport()
{
return static::extensionLoaded('pgsql') && static::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql');
}
}

View File

@ -50,7 +50,7 @@ class BackendPage extends Form
);
$resourceTypes = array();
if (Platform::extensionLoaded('mysql') || Platform::extensionLoaded('pgsql')) {
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
$resourceTypes['ido'] = 'IDO';
}
$resourceTypes['livestatus'] = 'Livestatus';

View File

@ -49,7 +49,7 @@ class AuthenticationPage extends Form
);
$backendTypes = array();
if (Platform::extensionLoaded('mysql') || Platform::extensionLoaded('pgsql')) {
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
$backendTypes['db'] = t('Database');
}
if (Platform::extensionLoaded('ldap')) {

View File

@ -64,7 +64,7 @@ class PreferencesPage extends Form
$storageTypes = array();
$storageTypes['ini'] = t('File System (INI Files)');
if (Platform::extensionLoaded('mysql') || Platform::extensionLoaded('pgsql')) {
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
$storageTypes['db'] = t('Database');
}
$storageTypes['null'] = t('Don\'t Store Preferences');