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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alanmackenzie’s picture

Status: Active » Needs review
FileSize
1.15 KB

Patch attached

WebSinPat’s picture

Thank 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

Fatal error: Call to undefined function entitycache_supported_core_entities() in entitycache.drush.inc on line 14
Drush command terminated abnormally due to an unrecoverable error.

(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.)

WebSinPat’s picture

this 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.)

skwashd’s picture

Issue summary: View changes
Status: Needs review » Needs work

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

alanmackenzie’s picture

Status: Needs work » Needs review
FileSize
1.22 KB

@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.

Dave Reid’s picture

Status: Needs review » Needs work

create_function() requires PHP 5.3 and above. This is an additional dependency for this module that would need to be considered.

alanmackenzie’s picture

Status: Needs work » Needs review

@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

WebSinPat’s picture

patch in #5 seems to work for me.

SocialNicheGuru’s picture

yes it does

DamienMcKenna’s picture

Status: Needs review » Reviewed & tested by the community

Tested it (PHP 5.3.27, Drush 6.4) and it worked fine. I think this is good enough for RTBC.

DamienMcKenna’s picture

Assigned: alanmackenzie » Unassigned
skwashd’s picture

Status: Reviewed & tested by the community » Fixed

@alanmackenzie thanks for the patch and rerolling it based on my feedback. I have committed the patch from #5.

  • skwashd committed ef9cc36 on 7.x-1.x authored by alanmackenzie
    Issue #2086633 by alanmackenzie: Allow for the clearing of individual...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.