Issue #3308507 by neclimdul, Spokje, longwave: Remove Cache::keyFromQuery

merge-requests/2967/head
catch 2022-11-17 09:25:33 +00:00
parent 39aae61be5
commit afc9dc2c88
2 changed files with 19 additions and 0 deletions

View File

@ -136,6 +136,11 @@ class Cache {
* 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 @@ class Cache {
* 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));

View File

@ -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 @@ class CacheTest extends UnitTestCase {
$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);
}
}