diff -u b/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php --- b/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -334,8 +334,7 @@ '#weight' => $child->getWeight(), '#access' => $access, ]; - $cacheability->addCacheableDependency($access); - $cacheability->addCacheableDependency($child); + $cacheability->addCacheableDependency($access)->addCacheableDependency($child); } } reverted: --- b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php +++ a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php @@ -8,8 +8,6 @@ namespace Drupal\comment\Plugin\Menu\LocalTask; use Drupal\comment\CommentStorageInterface; -use Drupal\Core\Cache\Cache; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Menu\LocalTaskDefault; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; diff -u b/core/modules/contact/contact.module b/core/modules/contact/contact.module --- b/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -5,8 +5,8 @@ * Enables the use of personal and site-wide contact forms. */ +use Drupal\Core\Cache\RefinableCacheableDependencyInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\user\Entity\User; @@ -99,7 +99,7 @@ * Hides the 'Contact' tab on the user profile if the user does not have an * email address configured. */ -function contact_menu_local_tasks_alter(&$data, $route_name, CacheableMetadata &$cacheable_metadata) { +function contact_menu_local_tasks_alter(&$data, $route_name) { if ($route_name == 'entity.user.canonical') { foreach ($data['tabs'][0] as $href => $tab_data) { if ($href == 'entity.user.contact_form') { diff -u b/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module --- b/core/modules/system/tests/modules/menu_test/menu_test.module +++ b/core/modules/system/tests/modules/menu_test/menu_test.module @@ -5,6 +5,7 @@ * Module that implements various hooks for menu tests. */ +use Drupal\Core\Cache\RefinableCacheableDependencyInterface; use Drupal\Core\Url; /** @@ -29,7 +30,7 @@ /** * Implements hook_menu_local_tasks_alter(). */ -function menu_test_menu_local_tasks_alter(&$data, $route_name, \Drupal\Core\Cache\RefinableCacheableDependencyInterface &$cacheability) { +function menu_test_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) { if (in_array($route_name, array('menu_test.tasks_default'))) { $data['tabs'][0]['foo'] = array( '#theme' => 'menu_local_task', diff -u b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php --- b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php +++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php @@ -7,7 +7,6 @@ namespace Drupal\menu_test\Plugin\Menu\LocalTask; -use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Menu\LocalTaskDefault; use Drupal\Core\StringTranslation\StringTranslationTrait; diff -u b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php --- b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Menu; -use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Menu\LocalTaskDefault; use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Routing\RouteProviderInterface; diff -u b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php --- b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php @@ -417,12 +417,12 @@ ->method('getDefinitions') ->will($this->returnValue($definitions)); - // Setup some cacheablity metadata and ensure its merged together. + // Set up some cacheablity metadata and ensure its merged together. $definitions['menu_local_task_test_tasks_settings']['cache_tags'] = ['tag.example1']; $definitions['menu_local_task_test_tasks_settings']['cache_contexts'] = ['context.example1']; $definitions['menu_local_task_test_tasks_edit']['cache_tags'] = ['tag.example2']; $definitions['menu_local_task_test_tasks_edit']['cache_contexts'] = ['context.example2']; - // Test the cacheable metadata of access checking. + // Test the cacheability metadata of access checking. $definitions['menu_local_task_test_tasks_view_child1']['access'] = AccessResult::allowed()->addCacheContexts(['user.permissions']); $this->setupFactoryAndLocalTaskPlugins($definitions, 'menu_local_task_test_tasks_view'); @@ -439,12 +439,12 @@ ->method('getRawParameters') ->willReturn(new ParameterBag()); - $cacheable_metadata = new CacheableMetadata(); - $local_tasks = $this->manager->getTasksBuild('menu_local_task_test_tasks_view', $cacheable_metadata); + $cacheability = new CacheableMetadata(); + $local_tasks = $this->manager->getTasksBuild('menu_local_task_test_tasks_view', $cacheability); - // Ensure that all cacheable metadata is merged together. - $this->assertEquals(['tag.example1', 'tag.example2'], $cacheable_metadata->getCacheTags()); - $this->assertEquals(['context.example1', 'context.example2', 'route', 'user.permissions'], $cacheable_metadata->getCacheContexts()); + // Ensure that all cacheability metadata is merged together. + $this->assertEquals(['tag.example1', 'tag.example2'], $cacheability->getCacheTags()); + $this->assertEquals(['context.example1', 'context.example2', 'route', 'user.permissions'], $cacheability->getCacheContexts()); } protected function setupFactoryAndLocalTaskPlugins(array $definitions, $active_plugin_id) {