1
0
Fork 0

Merge pull request #7835 from bugreportuser/fix-htaccess-protect-problems

Fix htaccess-protect problems
pull/7897/head
Jordi Boggiano 2018-12-23 14:36:59 +01:00 committed by GitHub
commit 0e44d53bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 11 deletions

View File

@ -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];

View File

@ -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()) {