View source
<?php
function sqlsrv_REData(ReflectionExtension $re) {
$_data = [];
$_data['getName'] = $re
->getName() ?: NULL;
$_data['getVersion'] = $re
->getVersion() ?: NULL;
$_data['getClassName'] = PHP_EOL . implode(", ", $re
->getClassNames()) ?: NULL;
foreach ($re
->getConstants() as $key => $value) {
$_data['getConstants'] .= "\n{$key}:={$value}";
}
$_data['getDependencies'] = $re
->getDependencies() ?: NULL;
$_data['getFunctions'] = PHP_EOL . implode(", ", array_keys($re
->getFunctions())) ?: NULL;
$_data['getINIEntries'] = $re
->getINIEntries() ?: NULL;
$_data['isPersistent'] = $re
->isPersistent() ?: NULL;
$_data['isTemporary'] = $re
->isTemporary() ?: NULL;
return $_data;
}
function sqlsrv_requirements($phase) {
$requirements = array();
if ($phase == 'runtime') {
$connection = Database::getConnection();
$options = $connection
->getConnectionOptions();
$schema = $connection
->schema();
$version = $schema
->EngineVersion();
$requirements['sqlsrv_edition'] = array(
'title' => t('MS SQL Server'),
'severity' => REQUIREMENT_INFO,
'value' => t('@version [@level] @edition', array(
'@version' => $version['VERSION'],
'@level' => $version['LEVEL'],
'@edition' => $version['EDITION'],
)),
);
$size = $schema
->getSizeInfo();
$size_db = format_size($size->RowSizeMB * 1024 * 1024);
$requirements['sqlsrv_database'] = array(
'title' => t('MS SQL Server Database'),
'severity' => REQUIREMENT_INFO,
'value' => "{$options['database']} ({$size_db})",
);
$is_windows = strncasecmp(PHP_OS, 'WIN', 3) == 0;
if ($is_windows) {
$wincache_enabled = function_exists('wincache_ucache_info') && ($cache = @wincache_ucache_info());
$wincache_module = module_exists('wincachedrupal');
$requirements['sqlsrv_wincache_extension'] = array(
'title' => t('MS SQL Server Wincache extension'),
'value' => $wincache_enabled ? phpversion('wincache') : t('Not available'),
'severity' => $wincache_enabled ? REQUIREMENT_OK : REQUIREMENT_ERROR,
'description' => $wincache_enabled ? NULL : t('For performance reasons, the Wincache extension should be enabled.'),
);
$requirements['sqlsrv_wincache_integration'] = array(
'title' => t('MS SQL Server Wincache integration'),
'value' => $wincache_module ? t('Available') : t('Not available'),
'severity' => $wincache_module ? REQUIREMENT_OK : REQUIREMENT_WARNING,
'description' => $wincache_module ? NULL : t('The wincache drupal module should be enabled.') . ' <a href="https://www.drupal.org/project/wincachedrupal">https://www.drupal.org/project/wincachedrupal</a>',
);
}
$collation = $schema
->getCollation($options['database']);
$case_insensitive = stripos($collation, '_CI') !== FALSE;
$requirements['sqlsrv_encoding_database'] = array(
'title' => t('MS SQL Server Database encoding'),
'severity' => $case_insensitive ? REQUIREMENT_OK : REQUIREMENT_ERROR,
'description' => $case_insensitive ? NULL : t('Drupal needs a default case insensitive collation database to run on.'),
'value' => t('@collation', array(
'@collation' => $collation,
)),
);
$extensiondata = sqlsrv_REData(new ReflectionExtension('pdo_sqlsrv'));
$requirements['sqlsrv_pdo'] = array(
'title' => t('MS SQL Server PDO extension'),
'severity' => REQUIREMENT_OK,
'value' => t('@level', array(
'@level' => $extensiondata['getVersion'],
)),
);
}
return $requirements;
}