Skip to content

Commit

Permalink
Fix ProcessExecutor bootstrapping, fixes #10703
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Apr 7, 2022
1 parent 0efb557 commit 849bc51
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Composer/Command/CreateProjectCommand.php
Expand Up @@ -235,7 +235,7 @@ public function installProject(IOInterface $io, Config $config, InputInterface $
}
}

$process = new ProcessExecutor($io);
$process = $composer->getLoop()->getProcessExecutor();
$fs = new Filesystem($process);

// dispatch event
Expand Down
4 changes: 3 additions & 1 deletion src/Composer/Command/DiagnoseCommand.php
Expand Up @@ -80,6 +80,9 @@ protected function execute(InputInterface $input, OutputInterface $output)

$io->write('Checking composer.json: ', false);
$this->outputResult($this->checkComposerSchema());
$this->process = $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io);
} else {
$this->process = new ProcessExecutor($io);
}

if ($composer) {
Expand All @@ -92,7 +95,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);

$this->httpDownloader = Factory::createHttpDownloader($io, $config);
$this->process = new ProcessExecutor($io);

$io->write('Checking platform settings: ', false);
$this->outputResult($this->checkPlatform());
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Command/StatusCommand.php
Expand Up @@ -96,7 +96,7 @@ private function doExecute(InputInterface $input): int
$vcsVersionChanges = array();

$parser = new VersionParser;
$guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
$guesser = new VersionGuesser($composer->getConfig(), $composer->getLoop()->getProcessExecutor() ?? new ProcessExecutor($io), $parser);
$dumper = new ArrayDumper;

// list packages
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Downloader/FileDownloader.php
Expand Up @@ -89,7 +89,7 @@ public function __construct(IOInterface $io, Config $config, HttpDownloader $htt
$this->eventDispatcher = $eventDispatcher;
$this->httpDownloader = $httpDownloader;
$this->cache = $cache;
$this->process = $process ?: new ProcessExecutor($io);
$this->process = $process ?? new ProcessExecutor($io);
$this->filesystem = $filesystem ?: new Filesystem($this->process);

if ($this->cache && $this->cache->gcIsNecessary()) {
Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Downloader/VcsDownloader.php
Expand Up @@ -45,8 +45,8 @@ public function __construct(IOInterface $io, Config $config, ProcessExecutor $pr
{
$this->io = $io;
$this->config = $config;
$this->process = $process ?: new ProcessExecutor($io);
$this->filesystem = $fs ?: new Filesystem($this->process);
$this->process = $process ?? new ProcessExecutor($io);
$this->filesystem = $fs ?? new Filesystem($this->process);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/EventDispatcher/EventDispatcher.php
Expand Up @@ -71,7 +71,7 @@ public function __construct(PartialComposer $composer, IOInterface $io, ProcessE
{
$this->composer = $composer;
$this->io = $io;
$this->process = $process ?: new ProcessExecutor($io);
$this->process = $process ?? new ProcessExecutor($io);
$this->eventStack = array();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Package/Locker.php
Expand Up @@ -68,7 +68,7 @@ public function __construct(IOInterface $io, JsonFile $lockFile, InstallationMan
$this->contentHash = self::getContentHash($composerFileContents);
$this->loader = new ArrayLoader(null, true);
$this->dumper = new ArrayDumper();
$this->process = $process ?: new ProcessExecutor($io);
$this->process = $process ?? new ProcessExecutor($io);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Platform/HhvmDetector.php
Expand Up @@ -54,7 +54,7 @@ public function getVersion(): ?string
$this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
$hhvmPath = $this->executableFinder->find('hhvm');
if ($hhvmPath !== null) {
$this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
$this->processExecutor = $this->processExecutor ?? new ProcessExecutor();
$exitCode = $this->processExecutor->execute(
ProcessExecutor::escape($hhvmPath).
' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Repository/RepositoryManager.php
Expand Up @@ -51,7 +51,7 @@ public function __construct(IOInterface $io, Config $config, HttpDownloader $htt
$this->config = $config;
$this->httpDownloader = $httpDownloader;
$this->eventDispatcher = $eventDispatcher;
$this->process = $process ?: new ProcessExecutor($io);
$this->process = $process ?? new ProcessExecutor($io);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Repository/VcsRepository.php
Expand Up @@ -99,7 +99,7 @@ public function __construct(array $repoConfig, IOInterface $io, Config $config,
$this->repoConfig = $repoConfig;
$this->versionCache = $versionCache;
$this->httpDownloader = $httpDownloader;
$this->processExecutor = $process ?: new ProcessExecutor($io);
$this->processExecutor = $process ?? new ProcessExecutor($io);
}

public function getRepoName()
Expand Down

0 comments on commit 849bc51

Please sign in to comment.