1 views_plugin_cache.inc views_plugin_cache::get_results_key()

File

core/modules/views/plugins/views_plugin_cache.inc, line 290
Definition of views_plugin_cache.

Class

views_plugin_cache
The base plugin to handle caching.

Code

function get_results_key() {
  global $user;

  if (!isset($this->_results_key)) {

    $build_info = $this->view->build_info;

    $query_plugin = $this->view->display_handler->get_plugin('query');

    foreach (array('query', 'count_query') as $index) {
      // If the default query back-end is used generate SQL query strings from
      // the query objects.
      if ($build_info[$index] instanceof SelectQueryInterface) {
        $query = clone $build_info[$index];
        $query->preExecute();
        $build_info[$index] = (string) $query;
      }
    }
    $key_data = array(
      'build_info' => $build_info,
      'roles' => array_keys($user->roles),
      'super-user' => $user->uid == 1, // special caching for super user.
      'language' => $GLOBALS['language']->langcode,
      'base_url' => $GLOBALS['base_url'],
    );
    foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) {
      if (isset($_GET[$key])) {
        $key_data[$key] = $_GET[$key];
      }
    }

    $this->_results_key = $this->view->name . ':' . $this->display->id . ':results:' . md5(serialize($key_data));
  }

  return $this->_results_key;
}