Problem/Motivation
Follow-up from #3460598: Single directory component CSS asset library not picked up in admin theme immediately after module install without cache clear.
ModuleInstaller::instal() and drupal_flush_all_caches() both manually call various service cache clearing methods, such as \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
Module install doesn't call drupal_flush_all_caches() because it tries to be selective about which caches it clears to avoid cold starts, so we have duplicated and subtly different logic between the two.
For module install, we could have a service tag + interface, so that plugin.cache_clearer and library.discovery can subscribe to the tag and have their caches cleared automatically. We could also do the same thing in drupal_flush_all_caches().
Not sure if we also need a 'flush all caches' tag for the things that are different too.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | Screenshot 2024-09-19 at 2.51.58 PM.png | 19.58 KB | saurav-drupal-dev |
| #4 | mymodule-cache-clearing.patch | 203.26 KB | saurav-drupal-dev |
Issue fork drupal-3463657
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:
- 3463657-add-service-tags
changes, plain diff MR !9579 /
changes, plain diff MR !9535
Comments
Comment #4
saurav-drupal-dev commentedI've worked on this and added service tags for cache clearing. The main goal was to simplify the way caches are cleared, reducing the need to manually call different cache clearing methods.
Here's what I did:
1. I created a new service that uses tags to manage which caches should be cleared. This makes it easier to handle cache clearing in a more modular way.
2. I updated the existing
`drupal_flush_all_caches()`function so it uses this new service, allowing the cache clear operations to be handled dynamically based on the tags.3. I added unit tests to ensure everything works as expected. These tests check that the new service clears caches properly and doesn’t slow down performance.
and create a MR also attaching patch.
Comment #5
saurav-drupal-dev commentedComment #7
smustgrave commentedAll fixes should in MRs
Comment #9
saurav-drupal-dev commentedplease check i have create a MR.
Comment #10
saurav-drupal-dev commentedComment #11
smustgrave commentedDon’t know if you’re mixing issues but this was talking cache tags but the MR is adding new modules to core