ConfigEntityStorage::resetCache() does not call ConfigFactory::reset()

Created on 24 July 2018, over 6 years ago
Updated 26 August 2023, over 1 year ago

Problem

Given the following two script files in my web directory that I run with drush:

// In web/config-cache-test.php:
$storage = \Drupal::entityTypeManager()->getStorage('filter_format');
$ids = $storage->getQuery()->execute();
print_r($ids);

// This is important that this gets run in a separate process.
drush_invoke_process('@self', 'scr', ['config-create']);

// Attempt to reset the entity storage cache before querying again.
$storage->resetCache();

$ids = $storage->getQuery()->execute();
print_r($ids);

// In web/config-create.php:
$storage = \Drupal::entityTypeManager()->getStorage('filter_format');
$filter_format = $storage->create([
  'format' => 'test',
  'name' => 'Test',
]);
$filter_format->save();

Expected Results

➜  drush scr config-cache-test
Array
(
    [basic_html] => basic_html
    [full_html] => full_html
    [plain_text] => plain_text
    [restricted_html] => restricted_html
)
Array
(
    [basic_html] => basic_html
    [full_html] => full_html
    [plain_text] => plain_text
    [restricted_html] => restricted_html
    [test] => test
)

Actual Results

➜  drush scr config-cache-test
Array
(
    [basic_html] => basic_html
    [full_html] => full_html
    [plain_text] => plain_text
    [restricted_html] => restricted_html
)
Array
(
    [basic_html] => basic_html
    [full_html] => full_html
    [plain_text] => plain_text
    [restricted_html] => restricted_html
    // <--- Missing test ID here
)

But If I were to add \Drupal::configFactory()->reset(); in addition to the $storage->resetCache(); then it does work as expected.

Proposed Solution

Override \Drupal\Core\Config\Entity\ConfigEntityStorage::resetCache() and have it call $this->configFactory->reset() which should avoid needing to call two separate resets.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Configuration entity 

Last updated 2 days ago

Created by

🇺🇸United States dave reid Nebraska USA

Live updates comments and jobs are added and updated live.
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.71.5 2024