Commit afc9dc2c authored by catch's avatar catch
Browse files

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

parent 39aae61b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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));
+13 −0
Original line number Diff line number Diff line
@@ -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);
  }

}