Update the schema making the varchar columns utf8_bin in MySQL.

Fichier

./advagg.install, line 487

Code

function advagg_update_7206(&$sandbox) {
    $db_type = Database::getConnection()->databaseType();
    $tables_altered = array();
    if ($db_type === 'mysql') {
        module_load_include('install', 'advagg', 'advagg');
        $schema = advagg_schema();
        $schema = array_keys($schema);
        foreach ($schema as $table_name) {
            $table_name = Database::getConnection()->prefixTables('{' . db_escape_table($table_name) . '}');
            $results = db_query("SHOW FULL FIELDS FROM {$table_name}")->fetchAllAssoc('Field');
            foreach ($results as $row) {
                if (stripos($row->Type, 'varchar') !== FALSE && $row->Collation !== 'utf8_bin') {
                    db_query("ALTER TABLE {$table_name} MODIFY {$row->Field} {$row->Type} CHARACTER SET utf8 COLLATE utf8_bin");
                    $tables_altered[$table_name][] = $row->Field;
                }
            }
        }
    }
    if (empty($tables_altered)) {
        return t('Nothing needed to happen in AdvAgg.');
    }
    return t('The following columns inside of these database tables where converted to utf8_bin: <br />@data', array(
        '@data' => print_r($tables_altered, TRUE),
    ));
}