drupal_get_schema_versions

Versions
4.7 – 7
drupal_get_schema_versions($module)

Returns an array of available schema versions for a module.

Parameters

$module A module name.

Return value

If the module has updates, an array of available updates sorted by version. Otherwise, FALSE.

▾ 6 functions call drupal_get_schema_versions()

drupal_install_system in includes/install.inc
Callback to install the system module.
system_install in modules/system/system.install
Implement hook_install().
system_requirements in modules/system/system.install
Test and report Drupal installation requirements.
update_batch in includes/update.inc
Start the database update batch process.
update_get_update_list in includes/update.inc
Return a list of all the pending database updates.
_drupal_install_module in includes/install.inc
Callback to install an individual install profile module.

Code

includes/install.inc, line 93

<?php
function drupal_get_schema_versions($module) {
  $updates = &drupal_static(__FUNCTION__, NULL);
  if (!isset($updates[$module])) {
    $updates = array();
    // Prepare regular expression to match all possible defined hook_update_N().
    $regexp = '/^(?P<module>.+)_update_(?P<version>\d+)$/';
    $functions = get_defined_functions();
    // Narrow this down to functions ending with an integer, since all
    // hook_update_N() functions end this way, and there are other
    // possible functions which match '_update_'. We use preg_grep() here
    // instead of foreaching through all defined functions, since the loop
    // through all PHP functions can take significant page execution time
    // and this function is called on every administrative page via
    // system_requirements().
    foreach (preg_grep('/_\d+$/', $functions['user']) as $function) {
      // If this function is a module update function, add it to the list of
      // module updates.
      if (preg_match($regexp, $function, $matches)) {
        $updates[$matches['module']][] = $matches['version'];
      }
    }
    // Ensure that updates are applied in numerical order.
    foreach ($updates as &$module_updates) {
      sort($module_updates, SORT_NUMERIC);
    }
  }
  return isset($updates[$module]) ? $updates[$module] : FALSE;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.