Skip to content

Instantly share code, notes, and snippets.

@andypost
Created September 1, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andypost/77ff0a2872d7736b8d31 to your computer and use it in GitHub Desktop.
Save andypost/77ff0a2872d7736b8d31 to your computer and use it in GitHub Desktop.
diff --git a/dblib.install b/dblib.install
index 1e1b063..588d3a7 100644
--- a/dblib.install
+++ b/dblib.install
@@ -36,65 +36,76 @@ function dblib_requirements($phase) {
if ($phase == 'runtime') {
/* @var Connection $connection Database Connection */
- $connection = Database::getConnection();
- $options = $connection->getConnectionOptions();
- $schema = $connection->schema();
- $collation = $schema->getCollation();
-
- // Check encoding
- $requirements['dblib_encoding'] = array(
- 'title' => t('SQL Server Driver'),
- 'description' => t('Collation for current database'),
- 'severity' => REQUIREMENT_OK,
- 'value' => t('Current database collation: @collation', array('@collation' => $collation)),
- );
+ $connections = Database::getAllConnectionInfo();
+ $found = FALSE;
+ foreach ($connections as $connection_group) {
+ if ($found) {
+ break;
+ }
- // Report database version
- $version = $schema->EngineVersion();
- $requirements['dblib_edition'] = array(
- 'title' => t('SQL Server Driver'),
- 'description' => t('SQL Server version'),
- 'severity' => REQUIREMENT_OK,
- 'value' => t('Current database engine: "@name" - @version [@level] @edition',
- array('@version' => $version['VERSION'],
- '@level' => $version['LEVEL'],
- '@edition' => $version['EDITION'],
- '@name' => $options['database'])),
- );
-
- // Report PDO version
- $drivers = \PDO::getAvailableDrivers();
- $extensions = get_loaded_extensions();
- $extensiondata = dblib_REData(new ReflectionExtension('pdo_dblib'));
- $requirements['dblib_pdo'] = array(
- 'title' => t('SQL Server Driver'),
- 'description' => t('SQL Server PDO Version'),
- 'severity' => REQUIREMENT_OK,
- 'value' => t('Current SQL Server PDO: @level',
- array('@level' => $extensiondata['getVersion'])),
- );
+ foreach ($connection_group as $connection) {
+ if ($found = ($connection['driver'] === 'dblib')) {
+ $options = $connection->getConnectionOptions();
+ $schema = $connection->schema();
+ $collation = $schema->getCollation();
- // TODO: Report install function availability (SUBSTRING, CONCAT, IF, MD5, etc...)
- $schema = $connection->schema();
- $functions = $schema->DrupalSpecificFunctions();
- $briefing = array();
- $error = FALSE;
- foreach($functions as $function) {
- $exists = $schema->functionExists($function);
- $error = $exists === FALSE ? TRUE : $error;
- $briefing[] = $function . ':' . ($exists === TRUE ? 'YES' : 'NO');
+ // Check encoding
+ $requirements['dblib_encoding'] = array(
+ 'title' => t('SQL Server Driver'),
+ 'description' => t('Collation for current database'),
+ 'severity' => REQUIREMENT_OK,
+ 'value' => t('Current database collation: @collation', array('@collation' => $collation)),
+ );
+
+ // Report database version
+ $version = $schema->EngineVersion();
+ $requirements['dblib_edition'] = array(
+ 'title' => t('SQL Server Driver'),
+ 'description' => t('SQL Server version'),
+ 'severity' => REQUIREMENT_OK,
+ 'value' => t('Current database engine: "@name" - @version [@level] @edition',
+ array('@version' => $version['VERSION'],
+ '@level' => $version['LEVEL'],
+ '@edition' => $version['EDITION'],
+ '@name' => $options['database'])),
+ );
+
+ // Report PDO version
+ $drivers = \PDO::getAvailableDrivers();
+ $extensions = get_loaded_extensions();
+ $extensiondata = dblib_REData(new ReflectionExtension('pdo_dblib'));
+ $requirements['dblib_pdo'] = array(
+ 'title' => t('SQL Server Driver'),
+ 'description' => t('SQL Server PDO Version'),
+ 'severity' => REQUIREMENT_OK,
+ 'value' => t('Current SQL Server PDO: @level',
+ array('@level' => $extensiondata['getVersion'])),
+ );
+
+ // TODO: Report install function availability (SUBSTRING, CONCAT, IF, MD5, etc...)
+ $schema = $connection->schema();
+ $functions = $schema->DrupalSpecificFunctions();
+ $briefing = array();
+ $error = FALSE;
+ foreach($functions as $function) {
+ $exists = $schema->functionExists($function);
+ $error = $exists === FALSE ? TRUE : $error;
+ $briefing[] = $function . ':' . ($exists === TRUE ? 'YES' : 'NO');
+ }
+ $exists =$schema->CLREnabled();
+ $error = $exists === FALSE ? TRUE : $error;
+ $briefing[] = 'CLREnabled' . ':' . ($exists === TRUE ? 'YES' : 'NO');
+
+ $requirements['dblib_pdo'] = array(
+ 'title' => t('SQL Server Driver'),
+ 'description' => t('SQL Server Custom Functions'),
+ 'severity' => $error === TRUE ? REQUIREMENT_ERROR : REQUIREMENT_OK,
+ 'value' => implode($briefing, ' | '),
+ );
+ break;
+ }
+ }
}
- $exists =$schema->CLREnabled();
- $error = $exists === FALSE ? TRUE : $error;
- $briefing[] = 'CLREnabled' . ':' . ($exists === TRUE ? 'YES' : 'NO');
-
- $requirements['dblib_pdo'] = array(
- 'title' => t('SQL Server Driver'),
- 'description' => t('SQL Server Custom Functions'),
- 'severity' => $error === TRUE ? REQUIREMENT_ERROR : REQUIREMENT_OK,
- 'value' => implode($briefing, ' | '),
- );
-
}
return $requirements;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment