diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-11-02 21:30:14 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-11-02 21:37:09 +0100 |
commit | 17ffe46d0bdbe263b6ba60b880e922127a8c3647 (patch) | |
tree | dfcb4d13468db0ece3db171bb6f7fc0ba7846bae /lib/private/Config.php | |
parent | 65375320fb94fe3b7d0aaaecc9e66b7458ed6c1a (diff) | |
download | nextcloud-server-17ffe46d0bdbe263b6ba60b880e922127a8c3647.tar.gz nextcloud-server-17ffe46d0bdbe263b6ba60b880e922127a8c3647.zip |
Read the env variables only once
We read config.php an awefull lot of times. So it only makes sense to
kill this as much as wel can.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Config.php')
-rw-r--r-- | lib/private/Config.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/private/Config.php b/lib/private/Config.php index cbdbc5b2e64..0a868be7832 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -47,6 +47,8 @@ class Config { /** @var array Associative array ($key => $value) */ protected $cache = []; + /** @var array */ + protected $envCache = []; /** @var string */ protected $configDir; /** @var string */ @@ -88,9 +90,9 @@ class Config { * @return mixed the value or $default */ public function getValue($key, $default = null) { - $envValue = getenv(self::ENV_PREFIX . $key); - if ($envValue !== false) { - return $envValue; + $envKey = self::ENV_PREFIX . $key; + if (isset($this->envCache[$envKey])) { + return $this->envCache[$envKey]; } if (isset($this->cache[$key])) { @@ -222,6 +224,8 @@ class Config { flock($filePointer, LOCK_UN); fclose($filePointer); } + + $this->envCache = getenv(); } /** |