]> source.dussan.org Git - nextcloud-server.git/commitdiff
Read the env variables only once
authorRoeland Jago Douma <roeland@famdouma.nl>
Mon, 2 Nov 2020 20:30:14 +0000 (21:30 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Mon, 2 Nov 2020 20:37:09 +0000 (21:37 +0100)
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>
lib/private/Config.php

index cbdbc5b2e64db7c5ec3a894b3fd882651b69514c..0a868be783284577c30e2895c7b6648a45aba72e 100644 (file)
@@ -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();
        }
 
        /**