Loading core/lib/Drupal/Core/Extension/ModuleDependencyMessageTrait.php +2 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,8 @@ public function checkDependencyMessage(array $modules, $dependency, Dependency $ } // Check if the module is incompatible with the dependency constraints. $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version'] ?? ''); // Remove CORE_COMPATIBILITY- only from the start of the string. $version = preg_replace('/^(' . \Drupal::CORE_COMPATIBILITY . '\-)/', '', $modules[$dependency]->info['version'] ?? ''); if (!$dependency_object->isCompatible($version)) { $constraint_string = $dependency_object->getConstraintString(); return $this->t('@module_name (<span class="admin-missing">incompatible with</span> version @version)', [ Loading core/modules/system/system.install +2 −1 Original line number Diff line number Diff line Loading @@ -1058,7 +1058,8 @@ function system_requirements($phase) { // Check for an incompatible version. $required_file = $files[$required_module]; $required_name = $required_file->info['name']; $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version'] ?? ''); // Remove CORE_COMPATIBILITY- only from the start of the string. $version = preg_replace('/^(' . \Drupal::CORE_COMPATIBILITY . '\-)/', '', $required_file->info['version'] ?? ''); if (!$requirement->isCompatible($version)) { $requirements["$extension_name-$required_module"] = [ 'title' => t('Unresolved dependency'), Loading core/modules/system/tests/modules/dependency_version_test/dependency_version_test.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'Dependency version test' type: module description: 'Support module for version comparison checks.' package: Testing version: VERSION core/modules/system/tests/modules/dependency_version_test/dependency_version_test.module 0 → 100644 +25 −0 Original line number Diff line number Diff line <?php /** * @file * Module for testing the dependency version comparisons. */ use Drupal\Core\Extension\Extension; /** * Implements hook_system_info_alter(). */ function dependency_version_test_system_info_alter(&$info, Extension $file, $type) { // Simulate that the core version for Views module contains the string '8.x'. if ($file->getName() == 'views') { $info['version'] = '9.8.x-dev'; } // Make the test_module require Views 9.2, which should be compatible with // core version 9.8.x-dev from above. if ($file->getName() == 'test_module') { $info['dependencies'] = ['drupal:views (>=9.2)']; } } core/modules/system/tests/src/Functional/Module/DependencyTest.php +15 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,21 @@ public function testCoreCompatibility() { $this->assertModules(['common_test', 'system_core_semver_test'], TRUE); } /** * Tests the dependency checks when core version contains '8.x' within it. */ public function testCoreVersionContains8X() { // Enable the helper module that alters the version and dependencies. \Drupal::service('module_installer')->install(['dependency_version_test']); // Check that the above module installed OK. $this->drupalGet('admin/modules'); $this->assertModules(['dependency_version_test'], TRUE); // Check that test_module dependencies are met and the box is not greyed. $this->assertSession()->fieldEnabled('modules[test_module][enable]'); } /** * Tests enabling a module that depends on a module which fails hook_requirements(). */ Loading Loading
core/lib/Drupal/Core/Extension/ModuleDependencyMessageTrait.php +2 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,8 @@ public function checkDependencyMessage(array $modules, $dependency, Dependency $ } // Check if the module is incompatible with the dependency constraints. $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version'] ?? ''); // Remove CORE_COMPATIBILITY- only from the start of the string. $version = preg_replace('/^(' . \Drupal::CORE_COMPATIBILITY . '\-)/', '', $modules[$dependency]->info['version'] ?? ''); if (!$dependency_object->isCompatible($version)) { $constraint_string = $dependency_object->getConstraintString(); return $this->t('@module_name (<span class="admin-missing">incompatible with</span> version @version)', [ Loading
core/modules/system/system.install +2 −1 Original line number Diff line number Diff line Loading @@ -1058,7 +1058,8 @@ function system_requirements($phase) { // Check for an incompatible version. $required_file = $files[$required_module]; $required_name = $required_file->info['name']; $version = str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $required_file->info['version'] ?? ''); // Remove CORE_COMPATIBILITY- only from the start of the string. $version = preg_replace('/^(' . \Drupal::CORE_COMPATIBILITY . '\-)/', '', $required_file->info['version'] ?? ''); if (!$requirement->isCompatible($version)) { $requirements["$extension_name-$required_module"] = [ 'title' => t('Unresolved dependency'), Loading
core/modules/system/tests/modules/dependency_version_test/dependency_version_test.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'Dependency version test' type: module description: 'Support module for version comparison checks.' package: Testing version: VERSION
core/modules/system/tests/modules/dependency_version_test/dependency_version_test.module 0 → 100644 +25 −0 Original line number Diff line number Diff line <?php /** * @file * Module for testing the dependency version comparisons. */ use Drupal\Core\Extension\Extension; /** * Implements hook_system_info_alter(). */ function dependency_version_test_system_info_alter(&$info, Extension $file, $type) { // Simulate that the core version for Views module contains the string '8.x'. if ($file->getName() == 'views') { $info['version'] = '9.8.x-dev'; } // Make the test_module require Views 9.2, which should be compatible with // core version 9.8.x-dev from above. if ($file->getName() == 'test_module') { $info['dependencies'] = ['drupal:views (>=9.2)']; } }
core/modules/system/tests/src/Functional/Module/DependencyTest.php +15 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,21 @@ public function testCoreCompatibility() { $this->assertModules(['common_test', 'system_core_semver_test'], TRUE); } /** * Tests the dependency checks when core version contains '8.x' within it. */ public function testCoreVersionContains8X() { // Enable the helper module that alters the version and dependencies. \Drupal::service('module_installer')->install(['dependency_version_test']); // Check that the above module installed OK. $this->drupalGet('admin/modules'); $this->assertModules(['dependency_version_test'], TRUE); // Check that test_module dependencies are met and the box is not greyed. $this->assertSession()->fieldEnabled('modules[test_module][enable]'); } /** * Tests enabling a module that depends on a module which fails hook_requirements(). */ Loading