function apdqc_admin_sessions_table_update_schema in Asynchronous Prefetch Database Query Cache 7
Update the sessions table schema.
Parameters
bool $show_msg: Set to FALSE to not run drupal_set_message().
bool $reverse: Undo all the changes made to the sessions table.
Return value
bool Returns TRUE if changes where made.
2 calls to apdqc_admin_sessions_table_update_schema()
- apdqc_disable in ./
apdqc.install - Implements hook_disable().
- drush_apdqc in ./
apdqc.drush.inc - Drush command to all all the apdqc functions.
1 string reference to 'apdqc_admin_sessions_table_update_schema'
- apdqc_admin_operations_form in ./
apdqc.admin.inc - Form builder; perform apdqc operations.
File
- ./
apdqc.admin.inc, line 929 - Admin page callbacks for the apdqc module.
Code
function apdqc_admin_sessions_table_update_schema($show_msg = TRUE, $reverse = FALSE) {
$changed = FALSE;
if ($reverse === TRUE) {
variable_del('apdqc_sessions_schema');
// Unmodify sessions table.
$schema = drupal_get_schema_unprocessed('system', 'sessions');
$table = 'sessions';
$field = 'sid';
db_change_field($table, $field, $field, $schema['fields'][$field]);
$field = 'ssid';
db_change_field($table, $field, $field, $schema['fields'][$field]);
$field = 'hostname';
db_change_field($table, $field, $field, $schema['fields'][$field]);
$columns = array(
'sid',
'ssid',
'hostname',
);
apdqc_admin_change_table_collation_queries('sessions', 'utf8_general_ci', TRUE, $columns);
apdqc_admin_sessions_table_duplicates(TRUE, TRUE);
variable_del('apdqc_sessions_schema');
$changed = TRUE;
}
else {
// Modify sessions table.
$table = 'sessions';
$schema = apdqc_get_full_schema();
$table_name = Database::getConnection()
->prefixTables('{' . db_escape_table($table) . '}');
$results = db_query("SHOW FULL FIELDS FROM {$table_name}")
->fetchAllAssoc('Field');
$field = 'sid';
if ($results[$field]->Type !== 'char(43)') {
db_change_field($table, $field, $field, $schema[$table]['fields'][$field]);
$changed = TRUE;
}
$field = 'ssid';
if ($results[$field]->Type !== 'char(43)') {
db_change_field($table, $field, $field, $schema[$table]['fields'][$field]);
$changed = TRUE;
}
$field = 'hostname';
if ($results[$field]->Type !== 'varchar(45)') {
db_change_field($table, $field, $field, $schema[$table]['fields'][$field]);
$changed = TRUE;
}
$columns = array(
'sid',
'ssid',
'hostname',
);
$collation_changed = apdqc_admin_change_table_collation_queries('sessions', 'ascii_bin', TRUE, $columns);
if ($collation_changed) {
$changed = TRUE;
}
$other_tables_changed = apdqc_admin_sessions_table_duplicates(TRUE, FALSE);
if ($other_tables_changed) {
$changed = TRUE;
}
if ($show_msg !== FALSE) {
drupal_set_message(t('APDQC: sessions table schema has been updated.'));
}
variable_set('apdqc_sessions_schema', TRUE);
}
return $changed;
}