Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently we have this:
function menu_menu_delete(Menu $menu) {
menu_cache_clear_all();
// Invalidate the block cache to update menu-based derivatives.
if (module_exists('block')) {
drupal_container()->get('plugin.manager.block')->clearCachedDefinitions();
}
}
Which leads to awkward requirements like in #1978244: Allow for optional dependencies.
Let's just do this instead:
<?php
use Drupal\Core\Cache\Cache;
function menu_menu_delete(Menu $menu) {
menu_cache_clear_all();
Cache::invalidateTags(array('block_definitions' => TRUE);
}
Note: this would require changing block manager's cache tag to block_definitions, which I think makes sense.
Comment | File | Size | Author |
---|---|---|---|
#1 | cache-1980212-1.patch | 13.27 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettSo this has the benefit of not needing module_exists() calls.
But it may or may not be a problem, since CacheDecorator also includes a static cache.
We'll find out!