1
0
Fork 0

Fix require command to allow working on network mounts, fixes #8231

pull/8252/head
Jordi Boggiano 2019-07-29 17:42:34 +02:00
parent 79e4ff4373
commit 33759d02c4
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 9 additions and 5 deletions

View File

@ -26,6 +26,7 @@ use Composer\Plugin\PluginEvents;
use Composer\Repository\CompositeRepository;
use Composer\Repository\PlatformRepository;
use Composer\IO\IOInterface;
use Composer\Util\Silencer;
/**
* @author Jérémy Romey <jeremy@free-agent.fr>
@ -103,11 +104,6 @@ EOT
return 1;
}
if (!is_writable($this->file)) {
$io->writeError('<error>'.$this->file.' is not writable.</error>');
return 1;
}
if (filesize($this->file) === 0) {
file_put_contents($this->file, "{\n}\n");
@ -116,6 +112,14 @@ EOT
$this->json = new JsonFile($this->file);
$this->composerBackup = file_get_contents($this->json->getPath());
// check for writability by writing to the file as is_writable can not be trusted on network-mounts
// see https://github.com/composer/composer/issues/8231 and https://bugs.php.net/bug.php?id=68926
if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
$io->writeError('<error>'.$this->file.' is not writable.</error>');
return 1;
}
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
$repos = $composer->getRepositoryManager()->getRepositories();