diff --git a/src/Command/Module/UninstallCommand.php b/src/Command/Module/UninstallCommand.php index 603f00d76..71d36cead 100755 --- a/src/Command/Module/UninstallCommand.php +++ b/src/Command/Module/UninstallCommand.php @@ -170,11 +170,22 @@ protected function execute(InputInterface $input, OutputInterface $output) } if (!$force = $input->getOption('force')) { - $profile = drupal_get_profile(); + + // Get a list of installed profiles that will be excluded when calculating + // the dependency tree. + if (\Drupal::hasService('profile_handler')) { + // #1356276 adds the profile_handler service but it hasn't been committed + // to core yet so we need to check if it exists. + $profiles = \Drupal::service('profile_handler')->getProfileInheritance(); + } + else { + $profiles[drupal_get_profile()] = []; + } + $dependencies = []; while (list($module) = each($moduleList)) { foreach (array_keys($moduleData[$module]->required_by) as $dependency) { - if (isset($installedModules[$dependency]) && !isset($moduleList[$dependency]) && $dependency != $profile) { + if (isset($installedModules[$dependency]) && !isset($moduleList[$dependency]) && (!array_key_exists($dependency, $profiles))) { $dependencies[] = $dependency; } }