Issue #1002258 by tstoeckler, xjm, kathyh: Fixed D6 modules satisfy D7 module dependencies.

8.0.x
catch 2011-11-09 01:04:26 +09:00
parent e1b21e1278
commit 9d961cc2d3
11 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,7 @@
name = "System incompatible core version dependencies test"
description = "Support module for testing system dependencies."
package = Testing
version = VERSION
core = 8.x
hidden = TRUE
dependencies[] = system_incompatible_core_version_test

View File

@ -0,0 +1,6 @@
name = "System incompatible core version test"
description = "Support module for testing system dependencies."
package = Testing
version = VERSION
core = 5.x
hidden = TRUE

View File

@ -0,0 +1,8 @@
name = "System incompatible module version dependencies test"
description = "Support module for testing system dependencies."
package = Testing
version = VERSION
core = 8.x
hidden = TRUE
; system_incompatible_module_version_test declares version 1.0
dependencies[] = system_incompatible_module_version_test (>2.0)

View File

@ -0,0 +1,6 @@
name = "System incompatible module version test"
description = "Support module for testing system dependencies."
package = Testing
version = 1.0
core = 8.x
hidden = TRUE

View File

@ -264,6 +264,14 @@ function system_test_system_info_alter(&$info, $file, $type) {
if ($file->name == 'system_dependencies_test') {
$info['hidden'] = FALSE;
}
if (in_array($file->name, array(
'system_incompatible_module_version_dependencies_test',
'system_incompatible_core_version_dependencies_test',
'system_incompatible_module_version_test',
'system_incompatible_core_version_test',
))) {
$info['hidden'] = FALSE;
}
if ($file->name == 'requirements1_test' || $file->name == 'requirements2_test') {
$info['hidden'] = FALSE;
}

View File

@ -811,6 +811,7 @@ function system_modules($form, $form_state = array()) {
// Only display visible modules.
elseif (isset($visible_files[$requires])) {
$requires_name = $files[$requires]->info['name'];
// Disable this module if it is incompatible with the dependency's version.
if ($incompatible_version = drupal_check_incompatibility($v, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $files[$requires]->info['version']))) {
$extra['requires'][$requires] = t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
'@module' => $requires_name . $incompatible_version,
@ -818,6 +819,14 @@ function system_modules($form, $form_state = array()) {
));
$extra['disabled'] = TRUE;
}
// Disable this module if the dependency is incompatible with this
// version of Drupal core.
elseif ($files[$requires]->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
$extra['requires'][$requires] = t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
'@module' => $requires_name,
));
$extra['disabled'] = TRUE;
}
elseif ($files[$requires]->status) {
$extra['requires'][$requires] = t('@module (<span class="admin-enabled">enabled</span>)', array('@module' => $requires_name));
}

View File

@ -421,6 +421,35 @@ class ModuleDependencyTestCase extends ModuleTestCase {
$this->assertModules(array('system_dependencies_test'), FALSE);
}
/**
* Tests enabling a module that depends on an incompatible version of a module.
*/
function testIncompatibleModuleVersionDependency() {
// Test that the system_incompatible_module_version_dependencies_test is
// marked as having an incompatible dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
'@module' => 'System incompatible module version test (>2.0)',
'@version' => '1.0',
)), 'A module that depends on an incompatible version of a module is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_incompatible_module_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, t('Checkbox for the module is disabled.'));
}
/**
* Tests enabling a module that depends on a module with an incompatible core version.
*/
function testIncompatibleCoreVersionDependency() {
// Test that the system_incompatible_core_version_dependencies_test is
// marked as having an incompatible dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
'@module' => 'System incompatible core version test',
)), 'A module that depends on a module with an incompatible core version is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_incompatible_core_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, t('Checkbox for the module is disabled.'));
}
/**
* Tests enabling a module that depends on a module which fails hook_requirements().
*/