From e3ba881ab939599889c1b6ac54b16e8bdbf68d0b Mon Sep 17 00:00:00 2001 From: Manuel Adan <102244922+manueladan-nttdata@users.noreply.github.com> Date: Wed, 24 Jul 2024 21:39:11 +0200 Subject: [PATCH] Fixes #6073: Adds dependencies version constraints checking. --- src/Commands/pm/PmCommands.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Commands/pm/PmCommands.php b/src/Commands/pm/PmCommands.php index 30f4bfb135..a7127a6aa8 100644 --- a/src/Commands/pm/PmCommands.php +++ b/src/Commands/pm/PmCommands.php @@ -17,6 +17,7 @@ use Drush\Boot\DrupalBootLevels; use Drush\Commands\DrushCommands; use Drush\Drush; +use Drush\Exceptions\CommandFailedException; use Drush\Exceptions\UserAbortException; use Drush\Utils\StringUtils; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -340,6 +341,15 @@ public function addInstallDependencies($modules): array throw new MissingDependencyException("Unable to install modules: module '$module' is missing its dependency module $dependency."); } + /** @var \Drupal\Core\Extension\Dependency $requirement */ + $requirement = $module_data[$module]->requires[$dependency]; + $version_constraint = $requirement->getConstraintString(); + $installed_version = $module_data[$dependency]->info['version']; + if ($version_constraint && $installed_version && !$requirement->isCompatible($installed_version)) { + // The dependency does not exist. + throw new CommandFailedException("Unable to install modules: module '$module' requires version $version_constraint of $dependency, $installed_version installed."); + } + // Skip already installed modules. if (!isset($module_list[$dependency]) && !isset($installed_modules[$dependency])) { $module_list[$dependency] = $dependency;