Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be nice from an operational and development perspective to be able to purge individual entitycache caches via drush.
This is easily achieved by implementing hook_drush_cache_clear(&$types)
. Below is an example of output drush cc generates after implementing the hook and applying the patch.
alanmac@nix$ drush cc
Enter a number to choose which cache to clear.
[0] : Cancel
[1] : all
[2] : drush
[3] : theme-registry
[4] : menu
[5] : css-js
[6] : block
[7] : module-list
[8] : theme-list
[9] : registry
[10] : entitycache-comment
[11] : entitycache-file
[12] : entitycache-node
[13] : entitycache-taxonomy-term
[14] : entitycache-taxonomy-vocabulary
[15] : entitycache-user
[16] : views
Patch to follow.
Comment | File | Size | Author |
---|---|---|---|
#5 | entitycache-individual_cache_clear_via_drush_cc-2086633-5.patch | 1.22 KB | alanmackenzie |
Comments
Comment #1
alanmackenzie CreditAttribution: alanmackenzie commentedPatch attached
Comment #2
WebSinPat CreditAttribution: WebSinPat commentedThank you from the bottom of my heart for this patch. I just spent a very long frustrating day not realizing that my drush cc calls were not clearing the entitycache and so the config changes i was making were never making it out to the final rendered page.
The patch seems to work great, except:
After applying the patch, if entitycache is disabled, I get the following error when i try running drush cc
(aside: the reason my cc calls were not working is that i cannot run "drush cc all" due to memory limitations of my webhost, so I run "drush cc [cache]" on all the caches individually. which meant that without this patch i had no way to ever clear the entitycache-* caches.)
Comment #3
WebSinPat CreditAttribution: WebSinPat commentedthis is outside the scope of this issue that specifies the drush interface, but made me wonder: what about the admin_menu interface that also gives a dropdown of individual cache clear options?
(I don't need it, hardly ever use that preferring drush, but it came to mind.)
Comment #4
skwashd CreditAttribution: skwashd commentedI like the idea of this patch. It should be checking the "entity cache" key of the entity info array so we can clear any cached entity type/s via drush.
Comment #5
alanmackenzie CreditAttribution: alanmackenzie commented@WebSinPat
I believe the issue you're having with this patch is due to to the lack of memory available on your host as hook implementations are cached (the module-implements cache). Please try on an environment that doesn't suffer from the problems you described in comment #2.
Integration with admin_menu is a separate issue and patch. Best to stay focused in each issue as this increases the chances of individual patches making it into the mainline.
@skwashd
Thanks for your review. I agree with what you're saying and I've created a second patch.
Comment #6
Dave Reidcreate_function() requires PHP 5.3 and above. This is an additional dependency for this module that would need to be considered.
Comment #7
alanmackenzie CreditAttribution: alanmackenzie commented@DaveRied
I think you're confused, anonymous functions are new in 5.3 but create_function() has existed since 4.0.1.
You can check this yourself here: http://php.net/create_function
Comment #8
WebSinPat CreditAttribution: WebSinPat commentedpatch in #5 seems to work for me.
Comment #9
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedyes it does
Comment #10
DamienMcKennaTested it (PHP 5.3.27, Drush 6.4) and it worked fine. I think this is good enough for RTBC.
Comment #11
DamienMcKennaComment #12
skwashd CreditAttribution: skwashd commented@alanmackenzie thanks for the patch and rerolling it based on my feedback. I have committed the patch from #5.