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.

7 calls to drush_drupal_version()
DrupalBoot::bootstrap_drupal_root in lib/Drush/Boot/DrupalBoot.php
Bootstrap Drush with a valid Drupal Directory.
DrupalBoot::bootstrap_drupal_root_validate in lib/Drush/Boot/DrupalBoot.php
Validate the DRUSH_BOOTSTRAP_DRUPAL_ROOT phase.
drush_archive_guess_manifest in commands/core/archive.drush.inc
Try to find docroot and DB dump file in an extracted archive.
drush_drupal_major_version in includes/drupal.inc
Returns the Drupal major version number (6, 7, 8 ...)
drush_get_projects in commands/pm/pm.drush.inc
Obtain an array of installed projects off the extensions available.

... See full list

File

includes/drupal.inc, line 36
Utility functions related to Drupal.

Code

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

  if (!$version) {
    if (($drupal_root != NULL) || ($drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'))) {
      // Try and find D8.
      if (file_exists($drupal_root . '/autoload.php')) {
        // Load the autoloader so we can access the class constants.
        drush_drupal_load_autoloader($drupal_root);
        // Drush depends on bootstrap being loaded at this point.
        require_once $drupal_root . '/core/includes/bootstrap.inc';
        if (defined('Drupal::VERSION')) {
          $version = Drupal::VERSION;
        }
      }
      else {
        // D7 stores VERSION in bootstrap.inc.
        // D6 and below does it in system.module.
        $version_constant_paths = array('/includes/bootstrap.inc', '/modules/system/system.module');
        foreach ($version_constant_paths as $path) {
          if (file_exists($drupal_root . $path)) {
            require_once $drupal_root . $path;
            if (defined('VERSION')) {
              $version = VERSION;
              break;
            }
          }
        }
      }
    }
  }
  return $version;
}