You are here

function _views_fetch_data in Views (for Drupal 7) 8.3

Same name and namespace in other branches
  1. 6.3 includes/cache.inc \_views_fetch_data()
  2. 6.2 includes/cache.inc \_views_fetch_data()
  3. 7.3 includes/cache.inc \_views_fetch_data()

Fetch Views' data from the cache.

$param string|null $table (optional) The name of the table for which to fetch Views' data. If NULL, data for all tables will be retrieved

Parameters

bool $reset: (optional) Whether to rebuild the cache. Defaults to FALSE.

Return value

array An associative array of views data for the given table. If $table is NULL, the array will be keyed by table name, with each key corresponding to the data array for that table.

See also

hook_views_data()

1 call to _views_fetch_data()
views_fetch_data in ./views.module
Fetch Views' data from the cache

File

includes/cache.inc, line 24
Load Views' data so that it knows what is available to build queries from.

Code

function _views_fetch_data($table = NULL, $reset = FALSE) {
  $cache =& drupal_static(__FUNCTION__ . '_cache');
  $recursion_protection =& drupal_static(__FUNCTION__ . '_recursion_protected');
  $fully_loaded =& drupal_static(__FUNCTION__ . '_fully_loaded');
  if ($reset) {
    $cache = NULL;
    $fully_loaded = FALSE;
  }
  if ($table) {
    if (!isset($cache[$table])) {
      $cid = 'views_data:' . $table;
      $data = views_cache_get($cid, TRUE);
      if (!empty($data->data)) {
        $cache[$table] = $data->data;
      }
      else {

        // No cache entry, rebuild.
        $cache = _views_fetch_data_build();
        $fully_loaded = TRUE;
      }
    }
    if (isset($cache[$table])) {
      return $cache[$table];
    }
  }
  else {
    if (!$fully_loaded) {
      $data = views_cache_get('views_data', TRUE);
      if (!empty($data->data)) {
        $cache = $data->data;
      }
      if (empty($cache)) {
        $cache = _views_fetch_data_build();
      }
      $fully_loaded = TRUE;
    }
    return $cache;
  }

  // Return an empty array if there is no match.
  return array();
}