Since Composer 2.5.5: "HTTPS must be enabled for Composer downloads."

Created on 18 April 2023, about 1 year ago
Updated 16 May 2023, about 1 year ago

Problem/Motivation

After install the 2.7 version we have the issue "HTTPS must be enabled for Composer downloads." How we see the issue appears on ComposerSettingsValidator.php in Version 2.6 it was working. The problem the $setting is now converted to int, the getConfig returns a "true" so is converted wrong and the check on setting !== 1 is not working.

Steps to reproduce

In version 2.7 the check was written like bellow

  public function validateStagePreOperation(PreOperationStageEvent $event): void {
    $dir = $this->pathLocator->getProjectRoot();

    try {
      $setting = (int) $this->inspector->getConfig('secure-http', $dir);
    }
    catch (\Exception $exception) {
      $event->addErrorFromThrowable($exception, $this->t('Unable to determine Composer secure-http setting.'));
      return;
    }
    if ($setting !== 1) {
      $event->addError([
        $this->t('HTTPS must be enabled for Composer downloads. See <a href=":url">the Composer documentation</a> for more information.', [
          ':url' => 'https://getcomposer.org/doc/06-config.md#secure-http',
        ]),
      ]);
    }
  }

In version 2.6 the check was written like bellow

  public function validateStagePreOperation(PreOperationStageEvent $event): void {
    $config = $event->getStage()
      ->getActiveComposer()
      ->getComposer()
      ->getConfig();

    if ($config->get('secure-http') !== TRUE) {
      $event->addError([
        $this->t('HTTPS must be enabled for Composer downloads. See <a href=":url">the Composer documentation</a> for more information.', [
          ':url' => 'https://getcomposer.org/doc/06-config.md#secure-http',
        ]),
      ]);
    }
  }

Proposed resolution

Change the getConfig and return correct the true / false or change the check "if ($setting !== 1) {"

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ญSwitzerland cola

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

Comments & Activities

Production build 0.69.0 2024