diff --git a/core/includes/install.inc b/core/includes/install.inc index f39f2f4..d017773 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -637,9 +637,11 @@ function drupal_install_system() { // Set the schema version to the number of the last update provided by the // module, or the minimum core schema version. + $system_version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION; $system_versions = drupal_get_schema_versions('system'); - $system_version = $system_versions ? max($system_versions) : 0; - $system_version = max($system_version, \Drupal::CORE_MINIMUM_SCHEMA_VERSION); + if ($system_versions) { + $system_version = max(max($system_versions), $system_version); + } \Drupal::keyValue('system.schema')->set('system', $system_version); // System module needs to be enabled and the system/module lists need to be diff --git a/core/includes/schema.inc b/core/includes/schema.inc index 6e672e4..51653a1 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -8,6 +8,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Database\Database; use Drupal\Core\Utility\SchemaCache; +use Drupal\Core\Extension\ExtensionSchemaVersionException; /** * @addtogroup schemaapi @@ -138,7 +139,17 @@ function drupal_get_schema_versions($module) { } } // Ensure that updates are applied in numerical order. - foreach ($updates as &$module_updates) { + foreach ($updates as $module => &$module_updates) { + // No module is allowed to define a schema update of exactly + // \Drupal::CORE_MINIMUM_SCHEMA_VERSION because this is reserved for the minimum + // installed version. + if (in_array(\Drupal::CORE_MINIMUM_SCHEMA_VERSION, $module_updates)) { + throw new ExtensionSchemaVersionException(format_string("%module's hook_update_N() implementations must use N greater than @version.", array( + '%module' => $module, + '@version' => \Drupal::CORE_MINIMUM_SCHEMA_VERSION, + ))); + } + sort($module_updates, SORT_NUMERIC); } } diff --git a/core/includes/update.inc b/core/includes/update.inc index b17624f..e51af86 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -984,7 +984,7 @@ function update_get_update_list() { $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE); foreach ($modules as $module => $schema_version) { // Skip uninstalled and incompatible modules. - if ($schema_version == SCHEMA_UNINSTALLED || update_check_incompatibility($module)) { + if ($schema_version == SCHEMA_UNINSTALLED || $schema_version < \Drupal::CORE_MINIMUM_SCHEMA_VERSION || update_check_incompatibility($module)) { continue; } // Otherwise, get the list of updates defined by this module. diff --git a/core/lib/Drupal/Core/Extension/ExtensionSchemaVersionException.php b/core/lib/Drupal/Core/Extension/ExtensionSchemaVersionException.php new file mode 100644 index 0000000..2b166ac --- /dev/null +++ b/core/lib/Drupal/Core/Extension/ExtensionSchemaVersionException.php @@ -0,0 +1,13 @@ +