diff -u b/core/lib/Drupal/Core/Extension/ExtensionNameReservedException.php b/core/lib/Drupal/Core/Extension/ExtensionNameReservedException.php --- b/core/lib/Drupal/Core/Extension/ExtensionNameReservedException.php +++ b/core/lib/Drupal/Core/Extension/ExtensionNameReservedException.php @@ -8 +8 @@ -class ExtensionNameReservedException extends \Exception { } +class ExtensionNameReservedException extends \Exception {} diff -u b/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php --- b/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -153,12 +153,6 @@ throw new ExtensionNameLengthException("Module name '$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters'); } - // Throw an exception if a theme with the same name is enabled. - $installed_themes = $extension_config->get('theme') ?: []; - if (isset($installed_themes[$module])) { - throw new ExtensionNameReservedException("Module name $module is already in use by an enabled theme."); - } - // Load a new config object for each iteration, otherwise changes made // in hook_install() are not reflected in $extension_config. $extension_config = \Drupal::configFactory()->getEditable('core.extension'); @@ -174,6 +168,12 @@ throw new ExtensionNameLengthException("Module name '$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters'); } + // Throw an exception if a theme with the same name is enabled. + $installed_themes = $extension_config->get('theme') ?: []; + if (isset($installed_themes[$module])) { + throw new ExtensionNameReservedException("Module name $module is already in use by an enabled theme."); + } + // Load a new config object for each iteration, otherwise changes made // in hook_install() are not reflected in $extension_config. $extension_config = \Drupal::configFactory()->getEditable('core.extension');