_install_get_version_info

_install_get_version_info($version)

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, 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").

File

core/includes/install.core.inc, line 1417
API functions for installing Drupal.

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]+)    # 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;
}
doc_Drupal
2016-10-29 09:57:14
Comments
Leave a Comment

Please login to continue.