summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien McKenna2018-04-14 00:58:30 (GMT)
committerDamien McKenna2018-04-14 00:58:30 (GMT)
commit481b5c28302b277cdd3ae45424cf4e501aba3eac (patch)
tree096d0677d73f05a07defa9f3d7c1f4a34957ab22
parentda52b7b998383952a8155c23f3d60ce9914cfde5 (diff)
Issue #2071607 by joelpittet, andrewbelcher, Anybody: Saving a view causes the entire cache to be invalidated.7.x-3.20
-rw-r--r--includes/view.inc8
-rw-r--r--views.api.php5
-rw-r--r--views.module10
3 files changed, 16 insertions, 7 deletions
diff --git a/includes/view.inc b/includes/view.inc
index 6e6f9d0..13e4987 100644
--- a/includes/view.inc
+++ b/includes/view.inc
@@ -1892,8 +1892,9 @@ class view extends views_db_object {
$this->save_locale_strings();
- // Clear caches.
- views_invalidate_cache();
+ // Clear the relevant caches.
+ cache_clear_all('views_block_items:', 'cache_views', TRUE);
+ views_invalidate_cache('ctools_export:views_view:' . $this->name);
// Notify modules that this view has been saved.
module_invoke_all('views_view_save', $this);
@@ -1935,7 +1936,8 @@ class view extends views_db_object {
if ($clear) {
// Clear caches.
- views_invalidate_cache();
+ cache_clear_all('views_block_items:', 'cache_views', TRUE);
+ views_invalidate_cache('ctools_export:views_view:' . $this->name);
}
// Notify modules that this view has been deleted.
diff --git a/views.api.php b/views.api.php
index fd8f64b..ea53a37 100644
--- a/views.api.php
+++ b/views.api.php
@@ -1260,9 +1260,12 @@ function hook_views_ajax_data_alter(&$commands, $view) {
* This hook should fire whenever a view is enabled, disabled, created,
* updated, or deleted.
*
+ * @param string $cid
+ * The cache identifier that is being cleared.
+ *
* @see views_invalidate_cache()
*/
-function hook_views_invalidate_cache() {
+function hook_views_invalidate_cache($cid) {
cache_clear_all('views:*', 'cache_mymodule', TRUE);
}
diff --git a/views.module b/views.module
index 302aa03..58cfed4 100644
--- a/views.module
+++ b/views.module
@@ -1012,10 +1012,14 @@ function views_field_delete_instance($instance) {
/**
* Invalidate the views cache, forcing a rebuild on the next grab of table data.
+ *
+ * @param string $cid
+ * The cache identifier we want to clear. If no given, it will default to '*'
+ * which will clear the entire cache_views bin.
*/
-function views_invalidate_cache() {
+function views_invalidate_cache($cid = '*') {
// Clear the views cache.
- cache_clear_all('*', 'cache_views', TRUE);
+ cache_clear_all($cid, 'cache_views', TRUE);
// Clear the page and block cache.
cache_clear_all();
@@ -1024,7 +1028,7 @@ function views_invalidate_cache() {
variable_set('menu_rebuild_needed', TRUE);
// Allow modules to respond to the Views cache being cleared.
- module_invoke_all('views_invalidate_cache');
+ module_invoke_all('views_invalidate_cache', $cid);
}
/**