Yaffs site version 1.1
[yaffs-website] / vendor / drush / drush / commands / core / drupal / cache.inc
1 <?php
2 /**
3  * @file
4  *   Engine for the cache commands.
5  */
6
7 function _drush_cache_command_get($cid, $bin) {
8   if (is_null($bin)) {
9     $bin = _drush_cache_bin_default();
10   }
11   return cache_get($cid, $bin);
12 }
13
14 /**
15  * The default bin.
16  *
17  * @return string
18  */
19 function _drush_cache_bin_default() {
20   return 'cache';
21 }
22
23 function _drush_cache_command_set($cid, $data, $bin, $expire, $tags) {
24   // Convert the "expire" argument to a valid value for Drupal's cache_set().
25   if (is_null($bin)) {
26     $bin = _drush_cache_bin_default();
27   }
28   if ($expire == 'CACHE_TEMPORARY') {
29     $expire = CACHE_TEMPORARY;
30   }
31   if (!isset($expire) || $expire == 'CACHE_PERMANENT') {
32     $expire = CACHE_PERMANENT;
33   }
34
35   // D6/D7 don't natively support cache tags.
36   return cache_set($cid, $data, $bin, $expire);
37 }
38
39 function _drush_cache_clear_types($include_bootstrapped_types) {
40   $types = array(
41     'drush' => 'drush_cache_clear_drush',
42     'all' => 'drush_cache_clear_both',
43   );
44   if ($include_bootstrapped_types) {
45     $types += array(
46       'theme-registry' => 'drush_cache_clear_theme_registry',
47       'menu' => 'menu_rebuild',
48       'css-js' => 'drush_cache_clear_css_js',
49       'block' => 'drush_cache_clear_block',
50       'module-list' => 'drush_get_modules',
51       'theme-list' => 'drush_get_themes',
52     );
53   }
54   $drupal_version = drush_drupal_major_version();
55
56   if ($drupal_version >= 7) {
57     $types['registry'] = 'registry_update';
58   }
59   elseif ($drupal_version == 6 && function_exists('module_exists') && module_exists('autoload')) {
60     // TODO: move this to autoload module.
61     $types['registry'] = 'autoload_registry_update';
62   }
63
64   return $types;
65 }
66
67 function drush_cache_clear_theme_registry() {
68   if (drush_drupal_major_version() >= 7) {
69     drupal_theme_rebuild();
70   }
71   else {
72     cache_clear_all('theme_registry', 'cache', TRUE);
73   }
74 }
75
76 function drush_cache_clear_menu() {
77   return menu_router_rebuild();
78 }
79
80 function drush_cache_clear_css_js() {
81   _drupal_flush_css_js();
82   drupal_clear_css_cache();
83   drupal_clear_js_cache();
84 }
85
86 /**
87  * Clear the cache of the block output.
88  */
89 function drush_cache_clear_block() {
90   cache_clear_all(NULL, 'cache_block');
91 }
92
93 /**
94  * Clear caches internal to Drush core and Drupal.
95  */
96 function drush_cache_clear_both() {
97   drush_cache_clear_drush();
98   if (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
99     drupal_flush_all_caches();
100   }
101 }