cache.inc

  1. cis7 includes/cache.inc
  2. cis7 sites/all/modules/ulmus/ctools/includes/cache.inc
  3. cis7 sites/all/modules/ulmus/views/includes/cache.inc
  4. cle7 includes/cache.inc
  5. cle7 sites/all/modules/ulmus/ctools/includes/cache.inc
  6. cle7 sites/all/modules/ulmus/views/includes/cache.inc
  7. ecd7 includes/cache.inc
  8. ecd7 sites/all/modules/ulmus/views/includes/cache.inc
  9. ecd7 sites/all/modules/ulmus/ctools/includes/cache.inc
  10. elmsmedia7 includes/cache.inc
  11. elmsmedia7 sites/all/modules/ulmus/ctools/includes/cache.inc
  12. elmsmedia7 sites/all/modules/ulmus/views/includes/cache.inc
  13. harmony7 sites/all/modules/ulmus/views/includes/cache.inc
  14. harmony7 sites/all/modules/ulmus/ctools/includes/cache.inc
  15. harmony7 includes/cache.inc
  16. icor7 includes/cache.inc
  17. icor7 sites/all/modules/ulmus/views/includes/cache.inc
  18. icor7 sites/all/modules/ulmus/ctools/includes/cache.inc
  19. meedjum_blog7 sites/all/modules/ulmus/ctools/includes/cache.inc
  20. meedjum_blog7 sites/all/modules/ulmus/views/includes/cache.inc
  21. meedjum_blog7 includes/cache.inc
  22. mooc7 sites/all/modules/ulmus/ctools/includes/cache.inc
  23. mooc7 sites/all/modules/ulmus/views/includes/cache.inc
  24. mooc7 includes/cache.inc

Load Views' data so that it knows what is available to build queries from.

Functions

Namesort descending Description
views_cache_get Return data from the persistent views cache.
views_cache_set Set a cached item in the views cache.
_views_data_process_entity_types Links tables having an 'entity type' specified to the respective generic entity-type tables.
_views_fetch_data Fetch Views' data from the cache
_views_fetch_data_build Build and set the views data cache if empty.
_views_fetch_plugin_data Fetch the plugin data from cache.

File

sites/all/modules/ulmus/views/includes/cache.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Load Views' data so that it knows what is available to build queries from.
  5. */
  6. /**
  7. * Fetch Views' data from the cache
  8. *
  9. * @param $move
  10. * Under certain circumstances it makes sense to not get the moved table, but the old one.
  11. * One example is views_get_handler.
  12. */
  13. function _views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) {
  14. $cache = &drupal_static(__FUNCTION__ . '_cache');
  15. $recursion_protection = &drupal_static(__FUNCTION__ . '_recursion_protected');
  16. $fully_loaded = &drupal_static(__FUNCTION__ . '_fully_loaded');
  17. if ($reset) {
  18. $cache = NULL;
  19. $fully_loaded = FALSE;
  20. }
  21. if ($table) {
  22. if (!isset($cache[$table])) {
  23. $cid = 'views_data:' . $table;
  24. $data = views_cache_get($cid, TRUE);
  25. if (!empty($data->data)) {
  26. $cache[$table] = $data->data;
  27. }
  28. else {
  29. if (!$fully_loaded) {
  30. // No cache entry, rebuild.
  31. $cache = _views_fetch_data_build();
  32. $fully_loaded = TRUE;
  33. }
  34. }
  35. }
  36. if (isset($cache[$table])) {
  37. if (isset($cache[$table]['moved to']) && $move) {
  38. $moved_table = $cache[$table]['moved to'];
  39. if (!empty($recursion_protection[$table])) {
  40. // recursion detected!
  41. return NULL;
  42. }
  43. $recursion_protection[$table] = TRUE;
  44. $data = _views_fetch_data($moved_table);
  45. $recursion_protection = array();
  46. return $data;
  47. }
  48. return $cache[$table];
  49. }
  50. }
  51. else {
  52. if (!$fully_loaded) {
  53. $data = views_cache_get('views_data', TRUE);
  54. if (!empty($data->data)) {
  55. $cache = $data->data;
  56. }
  57. if (empty($cache)) {
  58. $cache = _views_fetch_data_build();
  59. }
  60. $fully_loaded = TRUE;
  61. }
  62. return $cache;
  63. }
  64. // Return an empty array if there is no match.
  65. return array();
  66. }
  67. /**
  68. * Build and set the views data cache if empty.
  69. */
  70. function _views_fetch_data_build() {
  71. views_include_handlers();
  72. $cache = module_invoke_all('views_data');
  73. foreach (module_implements('views_data_alter') as $module) {
  74. $function = $module . '_views_data_alter';
  75. $function($cache);
  76. }
  77. _views_data_process_entity_types($cache);
  78. // Keep a record with all data.
  79. views_cache_set('views_data', $cache, TRUE);
  80. // Save data in seperate cache entries.
  81. foreach ($cache as $key => $data) {
  82. $cid = 'views_data:' . $key;
  83. views_cache_set($cid, $data, TRUE);
  84. }
  85. return $cache;
  86. }
  87. /**
  88. * Links tables having an 'entity type' specified to the respective generic entity-type tables.
  89. */
  90. function _views_data_process_entity_types(&$data) {
  91. foreach ($data as $table_name => $table_info) {
  92. // Add in a join from the entity-table if an entity-type is given.
  93. if (!empty($table_info['table']['entity type'])) {
  94. $entity_table = 'views_entity_' . $table_info['table']['entity type'];
  95. $data[$entity_table]['table']['join'][$table_name] = array(
  96. 'left_table' => $table_name,
  97. );
  98. $data[$entity_table]['table']['entity type'] = $table_info['table']['entity type'];
  99. // Copy over the default table group if we have none yet.
  100. if (!empty($table_info['table']['group']) && empty($data[$entity_table]['table']['group'])) {
  101. $data[$entity_table]['table']['group'] = $table_info['table']['group'];
  102. }
  103. }
  104. }
  105. }
  106. /**
  107. * Fetch the plugin data from cache.
  108. */
  109. function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) {
  110. static $cache = NULL;
  111. if (!isset($cache) || $reset) {
  112. $start = microtime(TRUE);
  113. views_include('plugins');
  114. views_include_handlers();
  115. $cache = views_discover_plugins();
  116. }
  117. if (!$type && !$plugin) {
  118. return $cache;
  119. }
  120. elseif (!$plugin) {
  121. // Not in the if above so the else below won't run
  122. if (isset($cache[$type])) {
  123. return $cache[$type];
  124. }
  125. }
  126. elseif (isset($cache[$type][$plugin])) {
  127. return $cache[$type][$plugin];
  128. }
  129. // Return an empty array if there is no match.
  130. return array();
  131. }
  132. /**
  133. * Set a cached item in the views cache.
  134. *
  135. * This is just a convenience wrapper around cache_set().
  136. *
  137. * @param $cid
  138. * The cache ID of the data to store.
  139. * @param $data
  140. * The data to store in the cache. Complex data types will be automatically serialized before insertion.
  141. * Strings will be stored as plain text and not serialized.
  142. * @param $use_language
  143. * If TRUE, the data will be cached specific to the currently active language.
  144. */
  145. function views_cache_set($cid, $data, $use_language = FALSE) {
  146. global $language;
  147. if (variable_get('views_skip_cache', FALSE)) {
  148. return;
  149. }
  150. if ($use_language) {
  151. $cid .= ':' . $language->language;
  152. }
  153. cache_set($cid, $data, 'cache_views');
  154. }
  155. /**
  156. * Return data from the persistent views cache.
  157. *
  158. * This is just a convenience wrapper around cache_get().
  159. *
  160. * @param int $cid
  161. * The cache ID of the data to retrieve.
  162. * @param bool $use_language
  163. * If TRUE, the data will be requested specific to the currently active language.
  164. *
  165. * @return stdClass|bool
  166. * The cache or FALSE on failure.
  167. */
  168. function views_cache_get($cid, $use_language = FALSE) {
  169. global $language;
  170. if (variable_get('views_skip_cache', FALSE)) {
  171. return FALSE;
  172. }
  173. if ($use_language) {
  174. $cid .= ':' . $language->language;
  175. }
  176. return cache_get($cid, 'cache_views');
  177. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.