Verified Commit 9ac21a92 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3536939 by phenaproxima, savage1974, thejimbirch: The unpacker chokes...

Issue #3536939 by phenaproxima, savage1974, thejimbirch: The unpacker chokes on Composer platform dependencies, like `ext-mbstring`

(cherry picked from commit 47f443d0)
parent dadcf295
Loading
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

use Composer\Command\BaseCommand;
use Composer\Package\PackageInterface;
use Composer\Repository\PlatformRepository;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -54,7 +55,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
    // root package.
    if (empty($package_names)) {
      foreach ($composer->getPackage()->getRequires() as $link) {
        $package = $local_repo->findPackage($link->getTarget(), $link->getConstraint());
        $target = $link->getTarget();
        // Skip platform requirements, since those don't resolve to a real
        // package.
        // @see https://getcomposer.org/doc/articles/composer-platform-dependencies.md
        if (PlatformRepository::isPlatformPackage($target)) {
          continue;
        }
        $package = $local_repo->findPackage($target, $link->getConstraint());
        if ($package->getType() === Plugin::RECIPE_PACKAGE_TYPE) {
          $package_names[] = $package->getName();
        }
+8 −1
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public function testRecursiveUnpacking(): void {
    $this->assertSame("fixtures/recipe-c unpacked.\nfixtures/recipe-a unpacked.\nfixtures/recipe-b unpacked.\n", $stdOut);
    $root_composer_json = $this->getFileContents($root_project_path . '/composer.json');
    $this->assertSame([
      'ext-json',
      'composer/installers',
      'drupal/core-recipe-unpack',
      'fixtures/module-a',
@@ -159,7 +160,7 @@ public function testNoAutomaticDevUnpack(): void {

    // Assert the state of the root composer.json as no unpacking has occurred.
    $this->assertSame(['fixtures/recipe-a'], array_keys($root_composer_json['require-dev']));
    $this->assertSame(['composer/installers', 'drupal/core-recipe-unpack', 'fixtures/module-a'], array_keys($root_composer_json['require']));
    $this->assertSame(['composer/installers', 'drupal/core-recipe-unpack', 'ext-json', 'fixtures/module-a'], array_keys($root_composer_json['require']));

    // Ensure the resulting Composer files are valid.
    $this->runComposer('validate');
@@ -418,6 +419,7 @@ public function testRemoveRecipe(): void {
    $this->assertSame([
      'composer/installers',
      'drupal/core-recipe-unpack',
      'ext-json',
      'fixtures/recipe-a',
    ], array_keys($root_composer_json['require']));

@@ -427,6 +429,7 @@ public function testRemoveRecipe(): void {
    $this->assertSame([
      'composer/installers',
      'drupal/core-recipe-unpack',
      'ext-json',
    ], array_keys($root_composer_json['require']));

    // Ensure the resulting Composer files are valid.
@@ -452,6 +455,7 @@ public function testIgnoreRecipe(): void {
    $this->assertSame([
      'composer/installers',
      'drupal/core-recipe-unpack',
      'ext-json',
      'fixtures/recipe-a',
    ], array_keys($root_composer_json['require']));

@@ -487,6 +491,7 @@ public function testIgnoreDependentRecipe(): void {
    $this->assertStringContainsString("fixtures/recipe-a unpacked.", $stdOut);

    $this->assertSame([
      'ext-json',
      'composer/installers',
      'drupal/core-recipe-unpack',
      'fixtures/module-b',
@@ -543,6 +548,7 @@ public function testRecipeNotUnpackedIfInstallIsDeferred(): void {
    $this->assertSame([
      'composer/installers',
      'drupal/core-recipe-unpack',
      'ext-json',
      'fixtures/recipe-a',
    ], array_keys($root_composer_json['require']));
    $this->assertFileDoesNotExist($root_project_path . '/recipes/recipe-a/recipe.yml');
@@ -554,6 +560,7 @@ public function testRecipeNotUnpackedIfInstallIsDeferred(): void {
    $this->assertSame([
      'composer/installers',
      'drupal/core-recipe-unpack',
      'ext-json',
      'fixtures/recipe-a',
    ], array_keys($root_composer_json['require']));
    $this->assertFileExists($root_project_path . '/recipes/recipe-a/recipe.yml');
+2 −1
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@
  },
  "require": {
    "composer/installers": "*",
    "drupal/core-recipe-unpack": "*"
    "drupal/core-recipe-unpack": "*",
    "ext-json": "*"
  },
  "extra": {
    "installer-paths": {