diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-04-13 10:51:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-13 10:51:09 +0200 |
commit | 01f3698175694d9994c8ef0bb91745582edf3345 (patch) | |
tree | ceab09f088061b226f019a48822f6f03d2eb3005 /lib | |
parent | 7cb6038fca25b925b76a537a84d1e447bcc3ba1f (diff) | |
parent | 95a21e2f2a7515be1d91d3f70db9cf821f872294 (diff) | |
download | nextcloud-server-01f3698175694d9994c8ef0bb91745582edf3345.tar.gz nextcloud-server-01f3698175694d9994c8ef0bb91745582edf3345.zip |
Merge pull request #3966 from nextcloud/downstream-26570
Override config.php values through environment variables
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Config.php | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/private/Config.php b/lib/private/Config.php index e6a27a76b2e..f15854b6113 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -39,6 +39,9 @@ namespace OC; * configuration file of ownCloud. */ class Config { + + const ENV_PREFIX = 'NC_'; + /** @var array Associative array ($key => $value) */ protected $cache = array(); /** @var string */ @@ -71,15 +74,22 @@ class Config { } /** - * Gets a value from config.php + * Returns a config value * - * If it does not exist, $default will be returned. + * gets its value from an `NC_` prefixed environment variable + * if it doesn't exist from config.php + * if this doesn't exist either, it will return the given `$default` * * @param string $key key * @param mixed $default = null default value * @return mixed the value or $default */ public function getValue($key, $default = null) { + $envValue = getenv(self::ENV_PREFIX . $key); + if ($envValue !== false) { + return $envValue; + } + if (isset($this->cache[$key])) { return $this->cache[$key]; } |