Use Composer API in \Drupal\Composer\Plugin\RecipeUnpack\Plugin::unpackOnRequire() instead of backtrace and closures

Created on 7 May 2025, 5 days ago

Problem/Motivation

\Drupal\Composer\Plugin\RecipeUnpack\Plugin::unpackOnRequire() uses a backtrace and closures to reach into Composer's installer object. This approach is copied from Symfony Flex - see https://github.com/symfony/flex/blob/2.x/src/Flex.php#L218.

Proposed resolution

Once ๐Ÿ“Œ Dependencies should be 'unpacked' to the root composer.json and merged/resolved Active create an upstream issue against Composer to make it easier to get the list of packages that satisfies both Drupal's and Symfony's needs.

Remaining tasks

Create upstream issue etc.

User interface changes

none

Introduced terminology

none

API changes

not to Drupal.

Data model changes

none

Release notes snippet

n/a

๐Ÿ“Œ Task
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

composer

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @alexpott
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia himani_219

    After reviewing the Symfony Flex implementation and Composer plugin architecture, itโ€™s clear this workaround is necessary due to a missing Composer API that would allow plugins to inspect the packages being installed at `composer require` time.

    Iโ€™ve reviewed the proposal in #3355485 and support the recommendation to create an upstream Composer issue. Iโ€™ve filed a request (or added a comment to an existing Composer issue) suggesting a new event or API to cleanly expose the list of packages to be installed, which would allow us to remove the backtrace hack entirely.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    @himani_219 can you link the Composer github issue - thanks! I've looked in the recently update Composer issues and can not find it.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Just opened the upstream issue since I was always interested about having official support for the unpack feature fundamentals in Composer: https://github.com/composer/composer/issues/12401

Production build 0.71.5 2024