KeyValueExpirableFactory incorrectly chooses its storage

Created on 20 July 2016, almost 8 years ago
Updated 9 August 2023, 11 months ago

Problem/Motivation

Currently, the actual store used to provide the expirable KV storage is supposed to be defined by the factory.keyvalue.expirable parameter, which defaults to default: keyvalue.expirable.database.

However, this fallback is duplicated in KeyValueFactory::get(), which does this:

    if (!isset($this->stores[$collection])) {
      if (isset($this->options[$collection])) {
        $service_id = $this->options[$collection];
      }
      elseif (isset($this->options[static::DEFAULT_SETTING])) {  // 'keyvalue_expirable_default', not 'default'
        $service_id = $this->options[static::DEFAULT_SETTING];
      }
      else {
        $service_id = static::DEFAULT_SERVICE;
      }

As a result, if a specific store is not provided when trying to instantiate an expirable KV store, the first and second checks fail because the default parameter is called default in core.services.yml but used as keyvalue_expirable_default in code, so the logic falls back to the value of KeyValueExpirableFactory::DEFAULT_SERVICE.

AFAICS, we have five use cases in core for this: form_cache (see #2183275: Use cache for $form, kv for $form_state β†’ ), update.manager, update.manager, update.processor, user.private_tempstore and user.shared_tempstore.

There are two possible fixes: the simplest one is to change the factory.keyvalue.expirable section in default.services.yml, the better one is to fix that logic to use default.

Steps to reproduce

TBD

Proposed resolution

TBD

Remaining tasks

Determine if this is a fix we want to add
If yes determine best patch forward
BC layer + tests
Code review

If no close as works as designed

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

πŸ› Bug report
Status

Needs review

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated less than a minute ago

Created by

πŸ‡«πŸ‡·France fgm Paris, France

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024