Skip to content

Commit

Permalink
Fixes drush-ops#6073: Adds dependencies version constraints checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
manueladan-nttdata committed Jul 24, 2024
1 parent 7a3eebb commit e3ba881
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Commands/pm/PmCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e3ba881

Please sign in to comment.