function views_invalidate_cache

Same name and namespace in other branches
  1. 11.x core/modules/views/views.module \views_invalidate_cache()
  2. 10 core/modules/views/views.module \views_invalidate_cache()
  3. 9 core/modules/views/views.module \views_invalidate_cache()
  4. 8.9.x core/modules/views/views.module \views_invalidate_cache()

Invalidate the views cache, forcing a rebuild on the next grab of table data.

Deprecated

in drupal:11.5.0 and is removed from drupal:13.0.0. Instead, use \Drupal\views\Views::invalidateCache() for cache invalidation, and call the router.builder and views.route_subscriber services directly to require route rebuilding.

See also

https://www.drupal.org/node/3584050

File

core/modules/views/views.module, line 95

Code

function views_invalidate_cache() : void {
  @trigger_error(__METHOD__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. Instead, use  \\Drupal\\views\\Views::invalidateCache() for cache invalidation, and call the router.builder and views.route_subscriber services directly to require route rebuilding. See https://www.drupal.org/node/3584050', E_USER_DEPRECATED);
  // Set the menu as needed to be rebuilt.
  \Drupal::service('router.builder')->setRebuildNeeded();
  $module_handler = \Drupal::moduleHandler();
  // Reset the RouteSubscriber from views.
  \Drupal::getContainer()->get('views.route_subscriber')
    ->reset();
  // Invalidate the block cache to update views block derivatives.
  if ($module_handler->moduleExists('block')) {
    \Drupal::service('plugin.manager.block')->clearCachedDefinitions();
  }
  // Allow modules to respond to the Views cache being cleared.
  $module_handler->invokeAll('views_invalidate_cache');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.