Commit 481b5c28 authored by DamienMcKenna's avatar DamienMcKenna

Issue #2071607 by joelpittet, andrewbelcher, Anybody: Saving a view causes the...

Issue #2071607 by joelpittet, andrewbelcher, Anybody: Saving a view causes the entire cache to be invalidated.
parent da52b7b9
......@@ -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.
......
......@@ -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);
}
......
......@@ -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);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment