Issue #1507368 by Dave Reid, damiankloip, tim.plunkett, aspilicious: Added hook for when the view cache is invalidated.
parent
805048810a
commit
29be73c229
|
@ -490,8 +490,7 @@ function _views_drush_changestatus($viewnames = array(), $status = NULL) {
|
|||
variable_set('views_defaults', $views_status);
|
||||
views_invalidate_cache();
|
||||
drush_log(dt("Views cache was cleared"), 'ok');
|
||||
menu_router_rebuild();
|
||||
drush_log(dt("Menu cache was cleared"), 'ok');
|
||||
drush_log(dt("Menu cache is set to be rebuilt on the next request."), 'ok');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -722,9 +722,7 @@ function views_ui_add_form_save_submit($form, &$form_state) {
|
|||
$form_state['redirect'] = 'admin/structure/views';
|
||||
}
|
||||
$view->save();
|
||||
menu_router_rebuild();
|
||||
cache('cache_views')->flush();
|
||||
cache_invalidate(array('content' => TRUE));
|
||||
|
||||
$form_state['redirect'] = 'admin/structure/views';
|
||||
if (!empty($view->display['page'])) {
|
||||
$display = $view->display['page'];
|
||||
|
@ -2173,15 +2171,6 @@ function views_ui_edit_view_form_submit($form, &$form_state) {
|
|||
$form_state['view']->save();
|
||||
drupal_set_message(t('The view %name has been saved.', array('%name' => $form_state['view']->get_human_name())));
|
||||
|
||||
// Make sure menu items get rebuilt as neces
|
||||
menu_router_rebuild();
|
||||
|
||||
// Clear the views cache.
|
||||
cache('cache_views')->flush();
|
||||
|
||||
// Clear the page cache.
|
||||
cache_invalidate(array('content' => TRUE));
|
||||
|
||||
// Remove this view from cache so we can edit it properly.
|
||||
ctools_object_cache_clear('view', $form_state['view']->name);
|
||||
}
|
||||
|
|
|
@ -1862,9 +1862,8 @@ class View extends ViewsDbObject {
|
|||
|
||||
$this->save_locale_strings();
|
||||
|
||||
cache('cache_views')->delete('views_urls');
|
||||
// Clear the page cache as well.
|
||||
cache_invalidate(array('content' => TRUE));
|
||||
// Clear caches.
|
||||
views_invalidate_cache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1901,10 +1900,8 @@ class View extends ViewsDbObject {
|
|||
cache('cache_views')->delete('views_query:' . $this->name);
|
||||
|
||||
if ($clear) {
|
||||
// Clear the block and page caches.
|
||||
cache_invalidate(array('content' => TRUE));
|
||||
// Force a menu rebuild when a view is deleted.
|
||||
menu_router_rebuild();
|
||||
// Clear caches.
|
||||
views_invalidate_cache();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -603,7 +603,7 @@ function hook_views_plugins() {
|
|||
'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
return array(
|
||||
'module' => 'views', // This just tells our themes are elsewhere.
|
||||
'argument validator' => array(
|
||||
|
@ -1081,6 +1081,18 @@ function hook_views_ajax_data_alter(&$commands, $view) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow modules to respond to the Views cache being invalidated.
|
||||
*
|
||||
* This hook should fire whenever a view is enabled, disabled, created,
|
||||
* updated, or deleted.
|
||||
*
|
||||
* @see views_invalidate_cache()
|
||||
*/
|
||||
function hook_views_invalidate_cache() {
|
||||
cache('mymodule')->deletePrefix('views:*');
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
12
views.module
12
views.module
|
@ -951,7 +951,17 @@ function views_field_delete_instance($instance) {
|
|||
* Invalidate the views cache, forcing a rebuild on the next grab of table data.
|
||||
*/
|
||||
function views_invalidate_cache() {
|
||||
// Clear the views cache.
|
||||
cache('cache_views')->flush();
|
||||
|
||||
// Clear the page and block cache.
|
||||
cache_invalidate(array('content' => TRUE));
|
||||
|
||||
// Set the menu as needed to be rebuilt.
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
|
||||
// Allow modules to respond to the Views cache being cleared.
|
||||
module_invoke_all('views_invalidate_cache');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1675,8 +1685,6 @@ function views_export_view(&$view, $indent = '') {
|
|||
function views_export_status($view, $status) {
|
||||
ctools_export_set_object_status($view, $status);
|
||||
views_invalidate_cache();
|
||||
// Set the menu to be rebuilt.
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue