clear.cache.inc

  1. 3.x commands/core/clear.cache.inc
  2. 4.x commands/core/clear.cache.inc

Functions

File

commands/core/clear.cache.inc
View source
  1. <?php
  2. /**
  3. * Command callback for drush cache-clear.
  4. */
  5. function drush_core_cache_clear($type = NULL) {
  6. switch (drush_drupal_major_version()) {
  7. case 5:
  8. // clear preprocessor cache
  9. drupal_clear_css_cache();
  10. // clear core tables
  11. $core = array('cache', 'cache_filter', 'cache_menu', 'cache_page');
  12. $alltables = array_merge($core, module_invoke_all('devel_caches'));
  13. foreach ($alltables as $table) {
  14. cache_clear_all('*', $table, TRUE);
  15. }
  16. drush_print(dt('Cache cleared.'));
  17. break;
  18. case 6:
  19. case 7:
  20. default:
  21. $types = drush_cache_clear_types();
  22. if ($type) {
  23. drush_op('call_user_func', $types[$type]);
  24. drush_log(dt("'!name' cache was cleared", array('!name' => $type)), 'success');
  25. }
  26. else {
  27. $choice = drush_choice($types, 'Enter a number to choose which cache to clear.', '!key');
  28. if ($choice !== FALSE) {
  29. call_user_func($types[$choice]);
  30. drush_log(dt("'!name' cache was cleared", array('!name' => $choice)), 'success');
  31. }
  32. }
  33. break;
  34. }
  35. }
  36. function drush_cache_clear_types() {
  37. $types = array(
  38. 'all' => 'drupal_flush_all_caches',
  39. 'theme' => 'drush_cache_clear_theme_registry',
  40. 'menu' => 'menu_rebuild',
  41. 'css+js' => 'drush_cache_clear_css_js',
  42. );
  43. if (count(module_implements('node_grants'))) {
  44. $types['nodeaccess'] = 'node_access_rebuild';
  45. }
  46. return $types;
  47. }
  48. function drush_cache_clear_theme_registry() {
  49. drush_db_delete('cache', 'cid LIKE :theme_registry', array(':theme_registry' => 'theme_registry%'));
  50. }
  51. function drush_cache_clear_css_js() {
  52. _drupal_flush_css_js();
  53. drupal_clear_css_cache();
  54. drupal_clear_js_cache();
  55. }