diff --git a/core/core.services.yml b/core/core.services.yml index 6cb0b16..5f47922 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -692,7 +692,7 @@ services: calls: - [setContext, ['@?router.request_context']] url_generator: - class: Drupal\Core\Render\UrlGenerator + class: Drupal\Core\Render\CacheableMetadataAwareUrlGenerator arguments: ['@url_generator.uncacheable', '@renderer'] calls: - [setContext, ['@?router.request_context']] diff --git a/core/lib/Drupal/Core/Render/UrlGenerator.php b/core/lib/Drupal/Core/Render/CacheableMetadataAwareUrlGenerator.php similarity index 90% rename from core/lib/Drupal/Core/Render/UrlGenerator.php rename to core/lib/Drupal/Core/Render/CacheableMetadataAwareUrlGenerator.php index 6e76b8a..2e42fc5 100644 --- a/core/lib/Drupal/Core/Render/UrlGenerator.php +++ b/core/lib/Drupal/Core/Render/CacheableMetadataAwareUrlGenerator.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Render\UrlGenerator. + * Contains \Drupal\Core\Render\CacheableMetadataAwareUrlGenerator. */ namespace Drupal\Core\Render; @@ -14,7 +14,7 @@ /** * The cacheable URL generator; decorates the uncacheable URL generator. */ -class UrlGenerator implements UrlGeneratorInterface { +class CacheableMetadataAwareUrlGenerator implements UrlGeneratorInterface { /** * The uncacheable URL generator. @@ -93,7 +93,9 @@ public function generate($name, $parameters = array(), $absolute = FALSE) { */ public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_cacheability_metadata = FALSE) { $generated_url = $this->urlGenerator->generateFromRoute($name, $parameters, $options, TRUE); - $this->bubble($generated_url); + if (!$collect_cacheability_metadata) { + $this->bubble($generated_url); + } return $collect_cacheability_metadata ? $generated_url : $generated_url->getGeneratedUrl(); } @@ -102,7 +104,9 @@ public function generateFromRoute($name, $parameters = array(), $options = array */ public function generateFromPath($path = NULL, $options = array(), $collect_cacheability_metadata = FALSE) { $generated_url = $this->urlGenerator->generateFromPath($path, $options, TRUE); - $this->bubble($generated_url); + if (!$collect_cacheability_metadata) { + $this->bubble($generated_url); + } return $collect_cacheability_metadata ? $generated_url : $generated_url->getGeneratedUrl(); } diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index a9b4c47..783d6e4 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -538,7 +538,7 @@ protected function doRender(&$elements, $is_root_call = FALSE) { * {@inheritdoc} */ public function hasRenderContext() { - return isset(static::$context); + return isset(static::$context) && !static::$context->isEmpty(); } /** diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php index 4e5ac8d..da89224 100644 --- a/core/modules/views/src/Plugin/views/pager/SqlBase.php +++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php @@ -382,7 +382,8 @@ public function isCacheable() { * {@inheritdoc} */ public function getCacheContexts() { - // This needs to play well with any other exposed item on the page. + // The rendered link needs to play well with any other query parameter used + // on the page, like pager and exposed filter. return ['url.query_args']; } diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php index 8828812..8a594cf 100644 --- a/core/modules/views/src/Plugin/views/style/Table.php +++ b/core/modules/views/src/Plugin/views/style/Table.php @@ -444,7 +444,8 @@ public function getCacheContexts() { foreach ($this->options['info'] as $field_id => $info) { if (!empty($info['sortable'])) { - // This needs to play well with any other exposed item on the page. + // The rendered link needs to play well with any other query parameter + // used on the page, like pager and exposed filter. $contexts[] = 'url.query_args'; break; }