function drush_drupal_version

8.0.x drush_drupal_version($drupal_root = NULL)
6.x drush_drupal_version($drupal_root = NULL)
7.x drush_drupal_version($drupal_root = NULL)
3.x drush_drupal_version()
4.x drush_drupal_version($drupal_root = NULL)
5.x drush_drupal_version($drupal_root = NULL)
master drush_drupal_version($drupal_root = NULL)

Detects the version number of the current Drupal installation, if any. Returns FALSE if there is no current Drupal installation, or it is somehow broken.

Return value

A string containing the version number of the current Drupal installation, if any. Otherwise, return FALSE.

6 calls to drush_drupal_version()
drush_archive_guess_manifest in commands/core/
Try to find docroot and DB dump file in an extracted archive.
drush_drupal_major_version in includes/
Returns the Drupal major version number (6, 7, 8 ...)
_core_site_status_table in commands/core/
_drush_bootstrap_drupal_root in includes/
Bootstrap Drush with a valid Drupal Directory.
_drush_bootstrap_drupal_root_validate in includes/

... See full list


includes/, line 17
Utility functions related to Drupal.


function drush_drupal_version($drupal_root = NULL) {
  static $version = FALSE;

  if (!$version) {
    if (($drupal_root != NULL) || ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'))) {
      // D7 stores VERSION in D8 moved that to /core/includes (see below).
      $version_constant_paths = array('/modules/system/system.module', '/includes/');
      foreach ($version_constant_paths as $path) {
        if (file_exists($drupal_root . $path)) {
          require_once $drupal_root . $path;
      // We just might be dealing with an early Drupal version (pre 4.7)
      if (defined('VERSION')) {
        $version = VERSION;
      elseif (file_exists($drupal_root . '/core/vendor/autoload.php')) {
        // Recognize D8 so we can give a good error message.
        // Load the autoloader so we can access the class constants.
        require_once $drupal_root . '/core/vendor/autoload.php';
        // Drush depends on bootstrap being loaded at this point;
        require_once $drupal_root . '/core/includes/';
        if (defined('Drupal::VERSION')) {
          $version = Drupal::VERSION;
  return $version;