From 767462b4095d655145c8e71f801c9f2c6f9ad9b3 Mon Sep 17 00:00:00 2001 From: bugreportuser <37939393+bugreportuser@users.noreply.github.com> Date: Thu, 13 Dec 2018 12:15:45 -0600 Subject: [PATCH 1/3] Move config check after config read --- src/Composer/Factory.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index 1aac934a1..6df73ceb3 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -164,6 +164,16 @@ class Factory 'data-dir' => self::getDataDir($home), ))); + // load global config + $file = new JsonFile($config->get('home').'/config.json'); + if ($file->exists()) { + if ($io && $io->isDebug()) { + $io->writeError('Loading config file ' . $file->getPath()); + } + $config->merge($file->read()); + } + $config->setConfigSource(new JsonConfigSource($file)); + $htaccessProtect = (bool) $config->get('htaccess-protect'); if ($htaccessProtect) { // Protect directory against web access. Since HOME could be @@ -180,16 +190,6 @@ class Factory } } - // load global config - $file = new JsonFile($config->get('home').'/config.json'); - if ($file->exists()) { - if ($io && $io->isDebug()) { - $io->writeError('Loading config file ' . $file->getPath()); - } - $config->merge($file->read()); - } - $config->setConfigSource(new JsonConfigSource($file)); - // load global auth file $file = new JsonFile($config->get('home').'/auth.json'); if ($file->exists()) { From 2739fc05e9c40e7bae15fc40b229890db086ea3e Mon Sep 17 00:00:00 2001 From: bugreportuser <37939393+bugreportuser@users.noreply.github.com> Date: Thu, 13 Dec 2018 12:22:31 -0600 Subject: [PATCH 2/3] Read htaccess-protect as a bool --- src/Composer/Config.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 7b4220724..ad820ce3a 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -216,7 +216,6 @@ class Config case 'cache-vcs-dir': case 'cafile': case 'capath': - case 'htaccess-protect': // convert foo-bar to COMPOSER_FOO_BAR and check if it exists since it overrides the local config $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_')); @@ -230,6 +229,13 @@ class Config return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val); + case 'htaccess-protect': + $value = $this->getComposerEnv('COMPOSER_HTACCESS_PROTECT'); + if (false === $value) { + $value = $this->config[$key]; + } + return $value !== 'false' && (bool) $value; + case 'cache-ttl': return (int) $this->config[$key]; From 59360983c604bb44e8ada7a281c81046f8cd4ff5 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Thu, 17 Jan 2019 12:46:57 +0100 Subject: [PATCH 3/3] Archive: cleanup temp dir on download error --- src/Composer/Package/Archiver/ArchiveManager.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/Package/Archiver/ArchiveManager.php b/src/Composer/Package/Archiver/ArchiveManager.php index 22f8eeafe..6f8fa8a01 100644 --- a/src/Composer/Package/Archiver/ArchiveManager.php +++ b/src/Composer/Package/Archiver/ArchiveManager.php @@ -147,8 +147,13 @@ class ArchiveManager $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid(); $filesystem->ensureDirectoryExists($sourcePath); - // Download sources - $this->downloadManager->download($package, $sourcePath); + try { + // Download sources + $this->downloadManager->download($package, $sourcePath); + } catch (\Exception $e) { + $filesystem->removeDirectory($sourcePath); + throw $e; + } // Check exclude from downloaded composer.json if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {