summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/views/includes/cache.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/views/includes/cache.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/views/includes/cache.inc98
1 files changed, 63 insertions, 35 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/views/includes/cache.inc b/kolab.org/www/drupal-7.18/sites/all/modules/views/includes/cache.inc
index c655c21..59c1733 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/views/includes/cache.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/views/includes/cache.inc
@@ -15,54 +15,82 @@
function _views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) {
$cache = &drupal_static(__FUNCTION__ . '_cache');
$recursion_protection = &drupal_static(__FUNCTION__ . '_recursion_protected');
- if (!isset($cache) || $reset) {
- $start = microtime(TRUE);
- // NOTE: This happens whether we retrieve them from cache or otherwise.
-
- $data = views_cache_get('views_data', TRUE);
- if (!empty($data->data)) {
- $cache = $data->data;
+ $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 {
+ if (!$fully_loaded) {
+ // No cache entry, rebuild.
+ $cache = _views_fetch_data_build();
+ $fully_loaded = TRUE;
+ }
+ }
}
-
- if (empty($cache)) {
- views_include_handlers();
- $cache = module_invoke_all('views_data');
- foreach (module_implements('views_data_alter') as $module) {
- $function = $module . '_views_data_alter';
- $function($cache);
+ if (isset($cache[$table])) {
+ if (isset($cache[$table]['moved to']) && $move) {
+ $moved_table = $cache[$table]['moved to'];
+ if (!empty($recursion_protection[$table])) {
+ // recursion detected!
+ return NULL;
+ }
+ $recursion_protection[$table] = TRUE;
+ $data = _views_fetch_data($moved_table);
+ $recursion_protection = array();
+ return $data;
}
- _views_data_process_entity_types($cache);
-
- views_cache_set('views_data', $cache, TRUE);
+ return $cache[$table];
}
}
+ else {
+ if (!$fully_loaded) {
+ $data = views_cache_get('views_data', TRUE);
+ if (!empty($data->data)) {
+ $cache = $data->data;
+ }
- if (!$table) {
- return $cache;
- }
- if (isset($cache[$table])) {
- // Support old views_data entries conversion.
- if (isset($cache[$table]['moved to']) && $move) {
- $moved_table = $cache[$table]['moved to'];
- if (!empty($recursion_protection[$table])) {
- // recursion detected!
- return NULL;
+ if (empty($cache)) {
+ $cache = _views_fetch_data_build();
}
- $recursion_protection[$table] = TRUE;
- $data = _views_fetch_data($moved_table);
- $recursion_protection = array();
- return $data;
- }
- else {
- return $cache[$table];
+ $fully_loaded = TRUE;
}
+ return $cache;
}
-
// Return an empty array if there is no match.
return array();
}
/**
+ * Build and set the views data cache if empty.
+ */
+function _views_fetch_data_build() {
+ views_include_handlers();
+ $cache = module_invoke_all('views_data');
+ foreach (module_implements('views_data_alter') as $module) {
+ $function = $module . '_views_data_alter';
+ $function($cache);
+ }
+ _views_data_process_entity_types($cache);
+
+ // Keep a record with all data.
+ views_cache_set('views_data', $cache, TRUE);
+ // Save data in seperate cache entries.
+ foreach ($cache as $key => $data) {
+ $cid = 'views_data:' . $key;
+ views_cache_set($cid, $data, TRUE);
+ }
+ return $cache;
+}
+
+/**
* Links tables having an 'entity type' specified to the respective generic entity-type tables.
*/
function _views_data_process_entity_types(&$data) {