function _install_get_version_info

Same name in other branches
  1. 9 core/includes/install.core.inc \_install_get_version_info()
  2. 8.9.x core/includes/install.core.inc \_install_get_version_info()
  3. 11.x core/includes/install.core.inc \_install_get_version_info()

Extracts version information from a drupal core version string.

Parameters

string $version: Version info string (e.g., 8.0.0, 8.1.0, 8.0.0-dev, 8.0.0-unstable1, 8.0.0-alpha2, 8.0.0-beta3, 8.6.x, and 8.0.0-rc4).

Return value

array Associative array of version info:

  • major: Major version (e.g., "8").
  • minor: Minor version (e.g., "0").
  • patch: Patch version (e.g., "0").
  • extra: Extra version info (e.g., "alpha2").
  • extra_text: The text part of "extra" (e.g., "alpha").
  • extra_number: The number part of "extra" (e.g., "2").
3 calls to _install_get_version_info()
LocaleNonInteractiveDevInstallTest::getVersionStringToTest in core/modules/locale/tests/src/Functional/LocaleNonInteractiveDevInstallTest.php
Gets the version string to use in the translation file.
LocaleNonInteractiveInstallTest::getVersionStringToTest in core/modules/locale/tests/src/Functional/LocaleNonInteractiveInstallTest.php
Gets the version string to use in the translation file.
_install_prepare_import in core/includes/install.core.inc
Tells the translation import process that Drupal core is installed.

File

core/includes/install.core.inc, line 1512

Code

function _install_get_version_info($version) {
    preg_match('/
    (
      (?P<major>[0-9]+)    # Major release number.
      \\.          # .
      (?P<minor>[0-9]+)    # Minor release number.
      \\.          # .
      (?P<patch>[0-9]+|x)  # Patch release number.
    )             #
    (             #
      -           # - separator for "extra" version information.
      (?P<extra>   #
        (?P<extra_text>[a-z]+)  # Release extra text (e.g., "alpha").
        (?P<extra_number>[0-9]*)  # Release extra number (no separator between text and number).
      )           #
      |           # OR no "extra" information.
    )
    /sx', $version, $matches);
    return $matches;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.