diff --git a/core/lib/Drupal/Core/EventSubscriber/CacheRouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/CacheRouterRebuildSubscriber.php index 38007f5..fa844ae 100644 --- a/core/lib/Drupal/Core/EventSubscriber/CacheRouterRebuildSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/CacheRouterRebuildSubscriber.php @@ -4,6 +4,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Routing\RoutingEvents; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -18,6 +19,16 @@ public function onRouterFinished() { // Requested URLs that formerly gave a 403/404 may now be valid. // Also invalidate all cached routing. Cache::invalidateTags(['4xx-response', 'route_match']); + + // Invalidate full response caches. + // @todo Bubble up route_match to all responses. This though requires + // significant changes of various test coverage. + if ($cache = \Drupal::getContainer()->get('cache.dynamic_page_cache', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { + $cache->invalidateAll(); + } + if ($cache = \Drupal::getContainer()->get('cache.render', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { + $cache->invalidateAll(); + } } /** diff --git a/core/modules/rest/tests/src/Functional/ResourceTestBase.php b/core/modules/rest/tests/src/Functional/ResourceTestBase.php index 49ef8e5..1dc7e96 100644 --- a/core/modules/rest/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/ResourceTestBase.php @@ -152,8 +152,7 @@ protected function provisionResource($resource_type, $formats = [], $authenticat 'authentication' => $authentication, ] ])->save(); - // @todo Remove this in https://www.drupal.org/node/2815845. - drupal_flush_all_caches(); + \Drupal::service('router.builder')->rebuild(); } /**