Verified Commit 0445faf0 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3436804 by longwave: CacheCollector::normalizeLockName() is pointless

parent 495174e5
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ protected function updateCache($lock = TRUE) {

    // Lock cache writes to help avoid stampedes.
    $cid = $this->getCid();
    $lock_name = $this->normalizeLockName($cid . ':' . __CLASS__);
    $lock_name = $cid . ':' . __CLASS__;
    if (!$lock || $this->lock->acquire($lock_name)) {
      // Set and delete operations invalidate the cache item. Try to also load
      // an eventually invalidated cache entry, only update an invalidated cache
@@ -283,6 +283,8 @@ protected function updateCache($lock = TRUE) {
   *   An ASCII-encoded cache ID that is at most 255 characters long.
   */
  protected function normalizeLockName($cid) {
    @trigger_error(sprintf('%s is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. The lock service is responsible for normalizing the lock name. See https://www.drupal.org/node/3436961', __METHOD__), E_USER_DEPRECATED);

    // Nothing to do if the ID is a US ASCII string of 255 characters or less.
    $cid_is_ascii = mb_check_encoding($cid, 'ASCII');
    if (strlen($cid) <= 255 && $cid_is_ascii) {
+7 −0
Original line number Diff line number Diff line
@@ -66,4 +66,11 @@ public function getCacheMisses() {
    return $this->cacheMisses;
  }

  /**
   * {@inheritdoc}
   */
  public function normalizeLockName($cid) {
    return parent::normalizeLockName($cid);
  }

}
+8 −0
Original line number Diff line number Diff line
@@ -411,4 +411,12 @@ public function testUpdateCacheClearTags() {
    $this->assertEquals(2, $this->collector->getCacheMisses());
  }

  /**
   * @group legacy
   */
  public function testDeprecatedNormalizeLockName() {
    $this->expectDeprecation('Drupal\Core\Cache\CacheCollector::normalizeLockName is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. The lock service is responsible for normalizing the lock name. See https://www.drupal.org/node/3436961');
    $this->collector->normalizeLockName('lock');
  }

}