You are here

function apdqc_menu_get_item_alter in Asynchronous Prefetch Database Query Cache 7

Implements hook_menu_get_item_alter().

File

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

Code

function apdqc_menu_get_item_alter($router_item, $path, $original_map) {
  if (!function_exists('apdqc_run_prefetch_array') || !function_exists('apdqc_escape_string')) {
    return;
  }
  static $run_once;
  if (apdqc_get_bin_class_name('cache_views') === 'APDQCache') {
    if ($router_item['page_callback'] === 'views_page' || $router_item['access_callback'] === 'views_access') {
      if (!isset($run_once['views'])) {
        $run_once['views'] = TRUE;
        $table_keys_cache_prefetch = apdqc_views_get_unpack_options();
      }
      $args = $router_item['page_arguments'];
      $data = @unserialize($router_item['page_arguments']);
      if ($router_item['page_arguments'] === 'b:0;' || $data !== FALSE) {
        $args = $data;
      }
      $table_keys_cache_prefetch['cache_views'][] = 'ctools_export:views_view:' . apdqc_escape_string($args[0]);
      if ($args[0] === 'project_issue_project_searchapi') {
        $lang_shorthand = apdqc_get_lang();
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:search_api_index_project_issues:' . $lang_shorthand;
        if (apdqc_get_bin_class_name('cache_field') === 'APDQCache') {
          $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:node:project_module';
        }
      }
      if ($args[0] === 'project_issue_search_project_searchapi') {
        $lang_shorthand = apdqc_get_lang();
        $table_keys_cache_prefetch['cache_views'][] = 'views_data:search_api_index_project_issues:' . $lang_shorthand;
      }
    }
  }
  if (apdqc_get_bin_class_name('cache_views') === 'APDQCache') {
    if ($router_item['page_callback'] === 'theme') {
      $args = $router_item['page_arguments'];
      $data = @unserialize($router_item['page_arguments']);
      if ($router_item['page_arguments'] === 'b:0;' || $data !== FALSE) {
        $args = $data;
      }
      if ($args[0] === 'drupalorg_download') {
        $table_keys_cache_prefetch = apdqc_views_get_unpack_options();
        $table_keys_cache_prefetch['cache_views'][] = 'ctools_export:views_view:project_index';
        if (apdqc_get_bin_class_name('cache_field') === 'APDQCache') {
          $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:node:project_module';
        }
      }
    }
  }
  if (apdqc_get_bin_class_name('cache_field') === 'APDQCache') {
    if ($router_item['page_callback'] === 'project_issue_node_add') {
      $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:node:project_issue';
      $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle_extra:node:project_issue';
      $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle:comment:comment_node_project_issue';
      $table_keys_cache_prefetch['cache_field'][] = 'field_info:bundle_extra:comment:comment_node_project_issue';
    }
  }

  // Prefetch cache.
  if (!empty($table_keys_cache_prefetch)) {
    apdqc_run_prefetch_array($table_keys_cache_prefetch);
  }
}