Skip to content

Commit

Permalink
Merge branch 'master' into pooloptimizer
Browse files Browse the repository at this point in the history
* master:
  Update changelog
  Fix regression handling installs with custom installers not passing a fully qualified path to downloaders, fixes composer#9431, fixes composer#9434
  Update changelog for 2.0.5
  Fix check-platform-reqs --no-dev to not require lock anymore
  Drop unused imports
  Fix missing directory separator in FileDownloader
  Avoid using curl when it has been disabled, fixes composer#9423
  • Loading branch information
Toflar committed Nov 9, 2020
2 parents 16ed5f6 + 86f0c10 commit d1b4e07
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 17 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,19 @@
### [2.0.6] 2020-11-07

* Fixed regression in 2.0.5 dealing with custom installers which do not pass absolute paths

### [2.0.5] 2020-11-06

* Disabled platform-check verification of extensions by default (now defaulting `php-only`), set platform-check to `true` if you want a complete check
* Improved platform-check handling of issue reporting
* Fixed platform-check to only check non-dev requires even if require-dev dependencies are installed
* Fixed issues dealing with custom installers which return trailing slashes in getInstallPath (ideally avoid doing this as there might be other issues left)
* Fixed issues when curl functions are disabled
* Fixed gitlab-domains/github-domains to make sure if they are overridden the default value remains present
* Fixed issues removing/upgrading packages from path repositories on Windows
* Fixed regression in 2.0.4 when handling of git@bitbucket.org URLs in vcs repositories
* Fixed issue running create-project in current directory on Windows

### [2.0.4] 2020-10-30

* Fixed `check-platform-req` command not being clear on what packages are checked, and added a --lock flag to explicitly check the locked packages
Expand Down Expand Up @@ -1033,6 +1049,8 @@

* Initial release

[2.0.6]: https://github.com/composer/composer/compare/2.0.5...2.0.6
[2.0.5]: https://github.com/composer/composer/compare/2.0.4...2.0.5
[2.0.4]: https://github.com/composer/composer/compare/2.0.3...2.0.4
[2.0.3]: https://github.com/composer/composer/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/composer/composer/compare/2.0.1...2.0.2
Expand Down
24 changes: 14 additions & 10 deletions src/Composer/Command/CheckPlatformReqsCommand.php
Expand Up @@ -29,7 +29,7 @@ protected function configure()
$this->setName('check-platform-reqs')
->setDescription('Check that platform requirements are satisfied.')
->setDefinition(array(
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements, implies --lock.'),
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
))
->setHelp(
Expand All @@ -49,21 +49,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
$composer = $this->getComposer();

$requires = array();
if ($input->getOption('no-dev') || $input->getOption('lock')) {
if ($input->getOption('lock')) {
$this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
} else {
$this->getIO()->writeError('<warning>The --no-dev option implies --lock, checking platform requirements from lock file instead of vendor dir</warning>');
}
$removePackages = array();
if ($input->getOption('lock')) {
$this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
$installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
} else {
$installedRepo = $composer->getRepositoryManager()->getLocalRepository();
// fallback to lockfile if installed repo is empty
if (!$installedRepo->getPackages()) {
$this->getIO()->writeError('<warning>No vendor dir present, checking platform requirements from the lock file</warning>');
$installedRepo = $composer->getLocker()->getLockedRepository(true);
$this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
$installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
} else {
$this->getIO()->writeError('<info>Checking platform requirements for packages in the vendor dir</info>');
if ($input->getOption('no-dev')) {
$removePackages = $installedRepo->getDevPackageNames();
}

$this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
}
}
if (!$input->getOption('no-dev')) {
Expand All @@ -76,6 +77,9 @@ protected function execute(InputInterface $input, OutputInterface $output)

$installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
foreach ($installedRepo->getPackages() as $package) {
if (in_array($package->getName(), $removePackages, true)) {
continue;
}
foreach ($package->getRequires() as $require => $link) {
$requires[$require][] = $link;
}
Expand Down
6 changes: 5 additions & 1 deletion src/Composer/Command/DiagnoseCommand.php
Expand Up @@ -379,7 +379,11 @@ private function checkVersion($config)

private function getCurlVersion()
{
if (function_exists('curl_version')) {
if (extension_loaded('curl')) {
if (!HttpDownloader::isCurlEnabled()) {
return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
}

$version = curl_version();

return '<comment>'.$version['version'].'</comment> '.
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Downloader/ArchiveDownloader.php
Expand Up @@ -63,7 +63,7 @@ public function install(PackageInterface $package, $path, $output = true)
// avoid cleaning up $path if installing in "." for eg create-project as we can not
// delete the directory we are currently in on windows
if (!is_dir($path) || realpath($path) !== getcwd()) {
$this->addCleanupPath($package, realpath($path));
$this->addCleanupPath($package, $path);
}

$this->filesystem->ensureDirectoryExists($temporaryDir);
Expand Down
4 changes: 1 addition & 3 deletions src/Composer/Downloader/FileDownloader.php
Expand Up @@ -14,15 +14,13 @@

use Composer\Config;
use Composer\Cache;
use Composer\Factory;
use Composer\IO\IOInterface;
use Composer\IO\NullIO;
use Composer\Package\Comparer\Comparer;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\DependencyResolver\Operation\UninstallOperation;
use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;
use Composer\Plugin\PluginEvents;
use Composer\Plugin\PostFileDownloadEvent;
use Composer\Plugin\PreFileDownloadEvent;
Expand Down Expand Up @@ -310,7 +308,7 @@ public function install(PackageInterface $package, $path, $output = true)

$this->filesystem->emptyDirectory($path);
$this->filesystem->ensureDirectoryExists($path);
$this->filesystem->rename($this->getFileName($package, $path), $path . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
$this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/Composer/Util/HttpDownloader.php
Expand Up @@ -67,8 +67,7 @@ public function __construct(IOInterface $io, Config $config, array $options = ar
$this->options = array_replace_recursive($this->options, $options);
$this->config = $config;

// TODO enable curl only on 5.6+ if older versions cause any problem
if (extension_loaded('curl')) {
if (self::isCurlEnabled()) {
$this->curl = new Http\CurlDownloader($io, $config, $options, $disableTls);
}

Expand Down Expand Up @@ -423,4 +422,9 @@ private function canUseCurl(array $job)

return true;
}

public static function isCurlEnabled()
{
return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
}
}

0 comments on commit d1b4e07

Please sign in to comment.