diff --git a/includes/view.inc b/includes/view.inc index 6e6f9d08344a96e4fe674a8984df55ee65aa067c..13e4987f112da5cfb2e1e886b7d80ee747fd18d2 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 fd8f64bcd60748ec164d9707c1e3b21b9f7e6144..ea53a37cfcc2053bba2bf93ada8039ffcd1ba72f 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 302aa03c9988d267f6ce0838a8a61168bea885b9..58cfed4fc40ce84e781bdc45fe152fb7dfa86163 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); } /**