You are here

function apdqc_ctools_plugin_pre_alter in Asynchronous Prefetch Database Query Cache 7

Implements hook_ctools_plugin_pre_alter().

File

./apdqc.module, line 956
Asynchronous Prefetch Database Query Cache module.

Code

function apdqc_ctools_plugin_pre_alter(&$plugin, &$plugin_type_info) {
  if (!function_exists('apdqc_run_prefetch_array') || !function_exists('apdqc_escape_string')) {
    return;
  }
  static $lang_shorthand;
  static $run_once;
  if (!isset($lang_shorthand)) {
    $lang_shorthand = apdqc_get_lang();
  }
  if ($plugin['name'] == 'user') {
    if (!isset($run_once['user'])) {
      $run_once['user'] = TRUE;
    }
  }
  $table_keys_cache_prefetch = array();
  if ($plugin['file'] === 'views_panes.inc' || $plugin['file'] === 'view_pane.inc') {
    if (!isset($run_once['views_panes'])) {
      $run_once['views_panes'] = TRUE;
      if (apdqc_get_bin_class_name('cache_views') === 'APDQCache') {
        $table_keys_cache_prefetch += apdqc_views_get_unpack_options();
      }
    }
  }
  if ($plugin['file'] === 'view.inc' || $plugin['file'] === 'views.inc') {
    if (!isset($run_once['views'])) {
      $run_once['views'] = TRUE;
      if (apdqc_get_bin_class_name('cache_views') === 'APDQCache') {
        $table_keys_cache_prefetch += apdqc_views_get_unpack_options();
        $data = cache_get('ctools_export_index:views_view', 'cache_views');
        if (!empty($data) && is_array($data->data) && !empty($data->data)) {
          foreach ($data->data as $name) {
            $table_keys_cache_prefetch['cache_views'][] = 'ctools_export:views_view:' . apdqc_escape_string($name);
          }
        }
        if (!empty($run_once['user'])) {
          $table_keys_cache_prefetch['cache_views'][] = 'views_data:users:' . $lang_shorthand;
        }
      }
    }
  }
  if ($plugin['name'] == 'entity_from_field') {
    if (!isset($run_once['entity_from_field'])) {
      $run_once['entity_from_field'] = TRUE;
      if (apdqc_get_bin_class_name('cache_field') === 'APDQCache') {
        $table_keys_cache_prefetch['cache_field'][] = 'field_info:fields';
        $table_keys_cache_prefetch['cache_field'][] = 'field_info:instances';
      }
    }
  }
  if (module_exists('panels')) {
    if (!isset($run_once['views_content_panes'])) {
      $run_once['views_content_panes'] = TRUE;
      if (apdqc_get_bin_class_name('cache_views') === 'APDQCache') {
        $table_keys_cache_prefetch['cache_views'][] = 'views_content_panes:' . $lang_shorthand;
      }
    }
  }
  if ($plugin['name'] == 'download_releases_link') {
    if (!isset($run_once['download_releases_link'])) {
      $run_once['download_releases_link'] = TRUE;
      if (apdqc_get_bin_class_name('cache_views') === 'APDQCache') {
        $table_keys_cache_prefetch['cache_views'][] = 'ctools_export:views_view:project_downloads';
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_project:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_files:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_file:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:file_managed:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_version:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_short_description:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_version_major:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_version_minor:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_version_patch:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_version_ext_weight:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_version_extra:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_version_ext_delta:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_recommended:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_update_status:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:field_data_field_release_build_type:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:project_release_supported_versions:' . $lang_shorthand;
      }
      if (apdqc_get_bin_class_name('cache_field') === 'APDQCache') {
        $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:node:project_release';
        $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:node:page';
        $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:node:section';
      }
    }
  }
  if ($plugin['name'] === 'taxonomy_term') {
    if (!isset($run_once['taxonomy_term'])) {
      $run_once['taxonomy_term'] = TRUE;
      if (apdqc_get_bin_class_name('cache_views') === 'APDQCache') {
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:taxonomy_term_data:' . $lang_shorthand;
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:taxonomy_index:' . $lang_shorthand;
      }
    }
  }

  // Prefetch cache.
  apdqc_run_prefetch_array($table_keys_cache_prefetch);
}