public function SiteAuditCheckDatabaseCollation::calculateScore in Site Audit 7
Same name and namespace in other branches
- 8.2 Check/Database/Collation.php \SiteAuditCheckDatabaseCollation::calculateScore()
Implements \SiteAudit\Check\Abstract\calculateScore().
Overrides SiteAuditCheckAbstract::calculateScore
File
- Check/
Database/ Collation.php, line 93 - Contains \SiteAudit\Check\Database\Collation.
Class
- SiteAuditCheckDatabaseCollation
- Class SiteAuditCheckDatabaseCollation.
Code
public function calculateScore() {
if (version_compare(DRUSH_VERSION, 7, '>=')) {
$sql = drush_sql_get_class();
$db_spec = $sql
->db_spec();
}
else {
$db_spec = _drush_sql_get_db_spec();
}
$sql_query = 'SELECT TABLE_NAME AS name ';
$sql_query .= ', TABLE_COLLATION AS collation ';
$sql_query .= 'FROM information_schema.TABLES ';
$sql_query .= 'WHERE TABLES.table_schema = :dbname ';
$sql_query .= 'AND TABLE_COLLATION NOT IN (:collation) ';
$result = db_query($sql_query, array(
':dbname' => $db_spec['database'],
':collation' => array(
'utf8_general_ci',
'utf8_unicode_ci',
'utf8_bin',
),
));
if (!$result
->rowCount()) {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
}
$warn = FALSE;
foreach ($result as $row) {
$this->registry['collation_tables'][$row->name] = $row->collation;
// Special case for old imports.
if ($row->collation == 'latin1_swedish_ci') {
$warn = TRUE;
}
}
if ($warn) {
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
}
return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
}