Problem/Motivation

Spotted while working on #2575105: Use cache collector for state.

CacheCollector contains a method to normalize the lock name before calling acquiring the lock:

    $lock_name = $this->normalizeLockName($cid . ':' . __CLASS__);
    if (!$lock || $this->lock->acquire($lock_name)) {

But this shouldn't be the cache collector's problem, the lock subsystem should deal with that - and it does:

  public function acquire($name, $timeout = 30.0) {
    $name = $this->normalizeName($name);

It turns out that CacheCollector::normalizeLockName() and DatabaseLockBackend::normalizeName() basically do the same thing. CacheCollector::normalizeLockName() predates #2872276: Database lock backend should normalize the lock name but no followup was created to remove other normalizations.

Steps to reproduce

Proposed resolution

Remove CacheCollector::normalizeLockName().

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3436804

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review
longwave’s picture

Issue summary: View changes

Looked for other instances by searching for ->acquire( and reading the surrounding code, didn't find any.

spokje’s picture

Status: Needs review » Reviewed & tested by the community

Explanation makes sense
Code changes make sense
Tests are green
-------------------------+
RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs change record

I think we should deprecate this for removal from 11.x. This is in an abstract class - the whole point it to extend it. I can't find any usages in contrib https://git.drupalcode.org/search?group_id=2&repository_ref=&scope=blobs... but it would not be surprising if someone somewhere calls this method. Can we open a 10.3.x branch that does the deprecation and create a CR?

longwave’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record

Added deprecation, test, and CR: https://www.drupal.org/node/3436961

spokje’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

alexpott’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed the removal to 11.x and the deprecation to 10.3.x.

Committed 1f1d1ab and pushed to 11.x. Thanks!
Committed 0445faf and pushed to 10.3.x. Thanks!

  • alexpott committed 0445faf0 on 10.3.x
    Issue #3436804 by longwave: CacheCollector::normalizeLockName() is...

  • alexpott committed 1f1d1ab3 on 11.x
    Issue #3436804 by longwave: CacheCollector::normalizeLockName() is...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.