diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 3461595..656e918 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -546,13 +546,6 @@ public function enable($module_list, $enable_dependencies = TRUE) { unset($module_list[$module]); continue; } - // Throw an exception if the module name is too long. - if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) { - throw new ExtensionNameLengthException(format_string('Module name %name is over the maximum allowed length of @max characters.', array( - '%name' => $module, - '@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, - ))); - } $module_list[$module] = $module_data[$module]->sort; // Add dependencies to the list, with a placeholder weight. @@ -574,6 +567,16 @@ public function enable($module_list, $enable_dependencies = TRUE) { $module_list = array_keys($module_list); } + foreach ($module_list as $module) { + // Throw an exception if the module name is too long. + if (strlen($module) > DRUPAL_EXTENSION_NAME_MAX_LENGTH) { + throw new ExtensionNameLengthException(format_string('Module name %name is over the maximum allowed length of @max characters.', array( + '%name' => $module, + '@max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, + ))); + } + } + // Required for module installation checks. include_once DRUPAL_ROOT . '/core/includes/install.inc'; diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnable.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnable.php index 43a8044..182294d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnable.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleEnable.php @@ -11,14 +11,14 @@ use Drupal\simpletest\WebTestBase; /** - * Tests module_enable(). + * Tests enabling modules. */ class ModuleEnable extends WebTestBase { public static function getInfo() { return array( 'name' => 'Module enable', - 'description' => 'Tests module_enable().', + 'description' => 'Tests enabling modules.', 'group' => 'Module', ); } @@ -52,7 +52,7 @@ function testModuleNameLength() { $module_name = 'invalid_module_name_over_the_maximum_allowed_character_length'; $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', array('%name' => $module_name)); try { - module_enable(array($module_name)); + $this->container('module_handler')->enable(array($module_name)); $this->fail($message); } catch (ExtensionNameLengthException $e) { @@ -62,7 +62,7 @@ function testModuleNameLength() { // Since for the UI, the submit callback uses FALSE, test that too. $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', array('%name' => $module_name)); try { - module_enable(array($module_name), FALSE); + $this->container('module_handler')->enable(array($module_name), FALSE); $this->fail($message); } catch (ExtensionNameLengthException $e) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ExistingModuleNameLengthUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ExistingModuleNameLengthUpgradePathTest.php index d1004cc..fc9d0e6 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ExistingModuleNameLengthUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ExistingModuleNameLengthUpgradePathTest.php @@ -42,7 +42,7 @@ public function testUpgradeAborts() { } $this->assertText('Module name too long'); - $this->assertNoFieldByXPath('//input[@type="submit"]', 'Allowed to continue with the update process.'); + $this->assertNoFieldByXPath('//input[@type="submit"]', 'Not allowed to continue with the update process.'); } }