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

Issue fork drupal-3463657

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

catch created an issue. See original summary.

saurav-drupal-dev made their first commit to this issue’s fork.

saurav-drupal-dev’s picture

cache clear

I'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.

saurav-drupal-dev’s picture

Status: Active » Needs review

smustgrave’s picture

Status: Needs review » Needs work

All fixes should in MRs

saurav-drupal-dev’s picture

please check i have create a MR.

saurav-drupal-dev’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Don’t know if you’re mixing issues but this was talking cache tags but the MR is adding new modules to core

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.