W3cubDocs

/Drupal 8

function drupal_get_installed_schema_version

drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE)

Returns the currently installed schema version for a module.

Parameters

string $module: A module name.

bool $reset: Set to TRUE after installing or uninstalling an extension.

bool $array: Set to TRUE if you want to get information about all modules in the system.

Return value

string|int The currently installed schema version, or SCHEMA_UNINSTALLED if the module is not installed.

Related topics

Schema API
API to handle database schemas.

File

core/includes/schema.inc, line 76
Schema API handling functions.

Code

function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
  static $versions = array();

  if ($reset) {
    $versions = array();
  }

  if (!$versions) {
    if (!$versions = \Drupal::keyValue('system.schema')->getAll()) {
      $versions = array();
    }
  }

  if ($array) {
    return $versions;
  }
  else {
    return isset($versions[$module]) ? $versions[$module] : SCHEMA_UNINSTALLED;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!schema.inc/function/drupal_get_installed_schema_version/8.1.x