5 * Utility functions related to Drupal.
11 * Detects the version number of the current Drupal installation,
12 * if any. Returns FALSE if there is no current Drupal installation,
13 * or it is somehow broken.
16 * A string containing the version number of the current
17 * Drupal installation, if any. Otherwise, return FALSE.
19 function drush_drupal_version($drupal_root = NULL) {
20 static $version = FALSE;
23 if (($drupal_root != NULL) || ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'))) {
24 $bootstrap = Drush::bootstrapManager()->bootstrapObjectForRoot($drupal_root);
26 $version = $bootstrap->getVersion($drupal_root);
33 function drush_drupal_cache_clear_all() {
34 drush_invoke_process('@self', 'cache-rebuild');
38 * Returns the Drupal major version number (6, 7, 8 ...)
40 function drush_drupal_major_version($drupal_root = NULL) {
41 $major_version = FALSE;
42 if ($version = drush_drupal_version($drupal_root)) {
43 $version_parts = explode('.', $version);
44 if (is_numeric($version_parts[0])) {
45 $major_version = (integer)$version_parts[0];
48 return $major_version;