diff --git a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php index 8ffeecd..a0f817f 100644 --- a/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php +++ b/core/lib/Drupal/Core/Cache/Context/QueryArgsCacheContext.php @@ -31,11 +31,11 @@ public static function getLabel() { public function getContext($query_arg = NULL) { if ($query_arg === NULL) { $query_string = $this->requestStack->getCurrentRequest()->getQueryString(); - return $query_string === NULL ? '' : $query_string; + return (string) $query_string; } $value = $this->requestStack->getCurrentRequest()->query->get($query_arg, NULL, TRUE); - return $value === NULL ? '' : http_build_query([$query_arg => $value], '', '&'); + return (string) http_build_query([$query_arg => $value], '', '&'); } /** diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php index f223d36..8e76480 100644 --- a/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/Context/QueryArgsCacheContextTest.php @@ -33,7 +33,7 @@ public function testGetContext($uri, array $context_tokens, array $expected_keys $cache_contexts_manager = new CacheContextsManager($container_prophecy->reveal(), ['url.query_args']); - $this->assertSame($expected_keys, $cache_contexts_manager->convertTokensToKeys($context_tokens)); + $this->assertSame($expected_keys, $cache_contexts_manager->convertTokensToKeys($context_tokens)->getKeys()); } /**