function drush_drupal_version

8.0.x drupal.inc drush_drupal_version($drupal_root = NULL)
6.x drupal.inc drush_drupal_version($drupal_root = NULL)
7.x drupal.inc drush_drupal_version($drupal_root = NULL)
3.x drush.inc drush_drupal_version()
4.x drush.inc drush_drupal_version($drupal_root = NULL)
5.x drupal.inc drush_drupal_version($drupal_root = NULL)
master drupal.inc 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.

3 calls to drush_drupal_version()
drush_drupal_major_version in includes/drush.inc
Returns the Drupal major version number (5, 6, 7 ...)
_core_site_status_table in commands/core/core.drush.inc
_drush_bootstrap_drupal_root in includes/environment.inc
Bootstrap Drush with a valid Drupal Directory.

File

includes/drush.inc, line 203
The drush API implementation and helpers.

Code

function drush_drupal_version() {
  static $version = FALSE;

  if (!$version) {
    if ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT')) {
      // D7 stores VERSION in bootstrap.inc
      $version_constant_paths = array('/modules/system/system.module', '/includes/bootstrap.inc');
      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;
      }
    }
  }
  return $version;
}