As of Composer 2.5.5, `composer config` JSON-encodes boolean values

Created on 31 March 2023, over 1 year ago
Updated 5 July 2023, about 1 year ago

Problem/Motivation

Composer 2.5.5 introduced a change that breaks us. When you run composer config to request the value of a boolean config option (like secure-http), it now returns true or false, instead of 1 or 0, like previous versions. Here is the line that changed in Composer: https://github.com/composer/composer/compare/2.5.4...2.5.5#diff-5473790d...

This is very problematic for us because we support 2.2.x and 2.5 or later. It means that the output of ComposerInspector::getConfig() is not reliable, since calling code is expected to know the "shape" of the returned value (this assumption is documented).

Proposed resolution

There are a few ways we could approach this.

  1. We could drop support for all versions of Composer below 2.5.5. This likely won't fly, since 2.2.x is an LTS line.
  2. We could expect calling code to handle this by changing things like if ($setting === 1) to if ($setting === 1 || $setting === 'true').
  3. We could change getConfig() in such a way that it normalizes the values for certain config keys (there is already precedent for this).
  4. We could introduce a BC layer of some sort, maybe a helper method like ComposerInspector::isTrue($value), which we could drop when we bump our Composer requirement to 2.5.5 or later.

Personally, I favor options #2 and #4.

Remaining tasks

Figure out the right fix and implement it with test coverage.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

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

Comments & Activities

Production build 0.71.5 2024