diff --git a/core/includes/schema.inc b/core/includes/schema.inc index 40ca702..6e672e4 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -8,7 +8,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Database\Database; use Drupal\Core\Utility\SchemaCache; -use Drupal\Core\Extension\ExtensionSchemaVersionException; /** * @addtogroup schemaapi @@ -139,17 +138,7 @@ function drupal_get_schema_versions($module) { } } // Ensure that updates are applied in numerical order. - foreach ($updates as $module_name => &$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_name's hook_update_N() implementations must use N greater than @version.", array( - '%module_name' => $module_name, - '@version' => \Drupal::CORE_MINIMUM_SCHEMA_VERSION, - ))); - } - + foreach ($updates as &$module_updates) { sort($module_updates, SORT_NUMERIC); } } diff --git a/core/includes/update.inc b/core/includes/update.inc index 30bea0f..5f0abf6 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -438,7 +438,13 @@ 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 || $schema_version < \Drupal::CORE_MINIMUM_SCHEMA_VERSION || update_check_incompatibility($module)) { + if ($schema_version == SCHEMA_UNINSTALLED || update_check_incompatibility($module)) { + continue; + } + // Display a requirements error if the user somehow has a schema version + // from the previous Drupal major version. + if ($schema_version < \Drupal::CORE_MINIMUM_SCHEMA_VERSION) { + $ret[$module]['warning'] = '' . $module . ' module cannot be updated. Its schema version is ' . $schema_version . ', which is from an earlier major release of Drupal. You will need to migrate the data for this module instead.'; continue; } // Otherwise, get the list of updates defined by this module. @@ -448,12 +454,16 @@ function update_get_update_list() { // are removed, it will == 0. $last_removed = module_invoke($module, 'update_last_removed'); if ($schema_version < $last_removed) { - $ret[$module]['warning'] = '' . $module . ' module can not be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update ' . $module . ' module, you will first need to upgrade to the last version in which these updates were available.'; + $ret[$module]['warning'] = '' . $module . ' module cannot be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update ' . $module . ' module, you will first need to upgrade to the last version in which these updates were available.'; continue; } $updates = drupal_map_assoc($updates); foreach (array_keys($updates) as $update) { + if ($update == \Drupal::CORE_MINIMUM_SCHEMA_VERSION) { + $ret[$module]['warning'] = '' . $module . ' module cannot be updated. It contains an update numbered as ' . \Drupal::CORE_MINIMUM_SCHEMA_VERSION . ' which is reserved for the earliest installation of a module in Drupal ' . \Drupal::CORE_COMPATIBILITY . ', before any updates. In order to update ' . $module . ' module, you will need to install a version of the module with valid updates.'; + continue 2; + } if ($update > $schema_version) { // The description for an update comes from its Doxygen. $func = new ReflectionFunction($module . '_update_' . $update); diff --git a/core/lib/Drupal/Core/Extension/ExtensionSchemaVersionException.php b/core/lib/Drupal/Core/Extension/ExtensionSchemaVersionException.php deleted file mode 100644 index 2b166ac..0000000 --- a/core/lib/Drupal/Core/Extension/ExtensionSchemaVersionException.php +++ /dev/null @@ -1,13 +0,0 @@ - 'Invalid update hook', - 'description' => 'Tests that a module implementing hook_update_8000() causes an exception to be thrown on update.', + 'description' => 'Tests that a module implementing hook_update_8000() causes an error to be displayed on update.', 'group' => 'Update API', ); } @@ -26,17 +47,17 @@ public static function getInfo() { function setUp() { parent::setUp(); require_once DRUPAL_ROOT . '/core/includes/update.inc'; + + $this->update_url = $GLOBALS['base_url'] . '/core/update.php'; + $this->update_user = $this->drupalCreateUser(array('administer software updates')); } function testInvalidUpdateHook() { - // Confirm that a module with hook_update_8000() cannot be installed. - try { - \Drupal::moduleHandler()->install(array('update_test_invalid_hook')); - $this->fail('Enabling a module with hook_update_8000() is disallowed.'); - } - catch (ExtensionSchemaVersionException $e) { - $this->pass('Enabling a module with hook_update_8000() is disallowed.'); - } + // Confirm that a module with hook_update_8000() cannot be updated. + $this->drupalLogin($this->update_user); + $this->drupalGet($this->update_url); + $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE)); + $this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.')); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Update/UpdatesWith7x.php b/core/modules/system/lib/Drupal/system/Tests/Update/UpdatesWith7x.php index 0808b97..4d85f9d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Update/UpdatesWith7x.php +++ b/core/modules/system/lib/Drupal/system/Tests/Update/UpdatesWith7x.php @@ -58,6 +58,6 @@ function testWith7x() { // Click through update.php with 'administer software updates' permission. $this->drupalLogin($this->update_user); $this->drupalPostForm($this->update_url, array(), t('Continue'), array('external' => TRUE)); - $this->assertText(t('No pending updates.')); + $this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.')); } } diff --git a/core/modules/system/tests/modules/update_test_invalid_hook/update_test_invalid_hook.install b/core/modules/system/tests/modules/update_test_invalid_hook/update_test_invalid_hook.install index c1160fa..0a33af7 100644 --- a/core/modules/system/tests/modules/update_test_invalid_hook/update_test_invalid_hook.install +++ b/core/modules/system/tests/modules/update_test_invalid_hook/update_test_invalid_hook.install @@ -10,4 +10,3 @@ */ function update_test_invalid_hook_update_8000() { } -