function Module::getSchemaUpdates

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Updater/Module.php \Drupal\Core\Updater\Module::getSchemaUpdates()
  2. 10 core/lib/Drupal/Core/Updater/Module.php \Drupal\Core\Updater\Module::getSchemaUpdates()

Returns available database schema updates once a new version is installed.

Return value

array

File

core/lib/Drupal/Core/Updater/Module.php, line 83

Class

Module
Defines a class for updating modules using <a href="/api/drupal/core%21lib%21Drupal%21Core%21FileTransfer%21FileTransfer.php/class/FileTransfer/8.9.x" title="Defines the base FileTransfer class." class="local">Drupal\Core\FileTransfer\FileTransfer</a> classes via <a href="/api/drupal/core%21authorize.php/8.9.x" title="Administrative script for running authorized file operations." class="local">authorize.php</a>.

Namespace

Drupal\Core\Updater

Code

public function getSchemaUpdates() {
    require_once DRUPAL_ROOT . '/core/includes/install.inc';
    require_once DRUPAL_ROOT . '/core/includes/update.inc';
    if (!self::canUpdate($this->name)) {
        return [];
    }
    module_load_include('install', $this->name);
    if (!($updates = drupal_get_schema_versions($this->name))) {
        return [];
    }
    $modules_with_updates = update_get_update_list();
    if ($updates = $modules_with_updates[$this->name]) {
        if ($updates['start']) {
            return $updates['pending'];
        }
    }
    return [];
}

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