From afc9dc2c88c596d35dc940afe77e172b7d97e444 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Thu, 17 Nov 2022 09:25:33 +0000 Subject: [PATCH] Issue #3308507 by neclimdul, Spokje, longwave: Remove Cache::keyFromQuery --- core/lib/Drupal/Core/Cache/Cache.php | 6 ++++++ core/tests/Drupal/Tests/Core/Cache/CacheTest.php | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index da380995950a..71fbc0db2c92 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -136,6 +136,11 @@ public static function getBins() { * call this function. Executing the query and formatting results should * happen in a #pre_render callback. * + * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. No + * replacement provided. + * + * @see https://www.drupal.org/node/3308507 + * * @param \Drupal\Core\Database\Query\SelectInterface $query * A select query object. * @@ -143,6 +148,7 @@ public static function getBins() { * A hash of the query arguments. */ public static function keyFromQuery(SelectInterface $query) { + @trigger_error(__METHOD__ . ' is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. No replacement provided. https://www.drupal.org/node/3322044', E_USER_DEPRECATED); $query->preExecute(); $keys = [(string) $query, $query->getArguments()]; return hash('sha256', serialize($keys)); diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php index 458eddcc99a1..6b226965c971 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php @@ -3,6 +3,9 @@ namespace Drupal\Tests\Core\Cache; use Drupal\Core\Cache\Cache; +use Drupal\Tests\Core\Database\Stub\Select; +use Drupal\Tests\Core\Database\Stub\StubConnection; +use Drupal\Tests\Core\Database\Stub\StubPDO; use Drupal\Tests\UnitTestCase; use Prophecy\Argument; use Drupal\Core\Cache\Context\CacheContextsManager; @@ -184,4 +187,14 @@ public function testBuildTags($prefix, array $suffixes, array $expected, $glue = $this->assertEquals($expected, Cache::buildTags($prefix, $suffixes, $glue)); } + /** + * @covers ::keyFromQuery + * @group legacy + */ + public function testKeyFromQuery() { + $this->expectDeprecation('Drupal\Core\Cache\Cache::keyFromQuery is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. No replacement provided. https://www.drupal.org/node/3322044'); + $query = new Select(new StubConnection(new StubPDO(), []), 'dne'); + Cache::keyFromQuery($query); + } + } -- GitLab