You are here

function apdqc_admin_convert_tables_indexes in Asynchronous Prefetch Database Query Cache 7

Convert table indexes to expire, created.

Parameters

bool $show_msg: Set to FALSE to not run drupal_set_message().

1 call to apdqc_admin_convert_tables_indexes()
drush_apdqc in ./apdqc.drush.inc
Drush command to all all the apdqc functions.
1 string reference to 'apdqc_admin_convert_tables_indexes'
apdqc_admin_operations_form in ./apdqc.admin.inc
Form builder; perform apdqc operations.

File

./apdqc.admin.inc, line 654
Admin page callbacks for the apdqc module.

Code

function apdqc_admin_convert_tables_indexes($show_msg = TRUE) {
  $cache_table_indexes_before = apdqc_get_cache_table_indexes();
  $missing_expire_created_index_before = FALSE;
  foreach ($cache_table_indexes_before as $indexes) {
    if (!isset($indexes['expire_created'])) {
      $missing_expire_created_index_before = TRUE;
      break;
    }
  }

  // Drop the expire index; use expire_created.
  $before = array(
    'expire',
  );
  $after = array(
    'expire',
    'created',
  );
  apdqc_convert_cache_index($before, $after);
  $cache_table_indexes_after = apdqc_get_cache_table_indexes();
  $missing_expire_created_index_after = FALSE;
  foreach ($cache_table_indexes_after as $indexes) {
    if (!isset($indexes['expire_created']) && isset($indexes['expire'])) {
      $missing_expire_created_index_after = TRUE;
      break;
    }
  }

  // Let user know it worked.
  if ($show_msg !== FALSE) {
    if ($missing_expire_created_index_before === FALSE) {
      drupal_set_message(t('APDQC: All cache tables indexes where already up to date.'));
    }
    elseif ($missing_expire_created_index_after === TRUE) {
      drupal_set_message(t('APDQC: All cache tables indexes where not updated. You need to do this manually by using a tool like phpmyadmin.'), 'error');
    }
    else {
      drupal_set_message(t('APDQC: All cache tables indexes where updated.'));
    }
  }
  variable_set('apdqc_table_indexes', TRUE);
}