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.
| Comment | File | Size | Author |
|---|---|---|---|
| #24 | interdiff_22-24.txt | 3.17 KB | vsujeetkumar |
| #24 | 2987978-24.patch | 4.91 KB | vsujeetkumar |
| #22 | 2987978-22.patch | 1.59 KB | Ajeet Tiwari |
| #20 | interdiff.txt | 256 bytes | zeeshan_khan |
| #20 | 2987978-7.patch | 789 bytes | zeeshan_khan |
Issue fork drupal-2987978
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
Comment #2
dave reidComment #3
dave reidComment #4
dave reidComment #6
dave reidTry that again...
Comment #10
dave reidComment #18
larowlanComment #20
zeeshan_khan commentedPatch rerolled with 11.x
Comment #21
chrisdarke commentedMigrating Pittsburgh 2023 to Pittsburgh2023 tag for cleanup
Comment #22
Ajeet Tiwari commentedPlease review.
Comment #24
vsujeetkumar commentedTest cases added, Removed tags, Please have a look.
Comment #25
smustgrave commentedThink the tests need to be tweaked. Even without the fix
testDelete
testSaveChangedUuid
testSaveRename
testSaveInsert
Still passed.