diff options
author | Robin Appelman <robin@icewind.nl> | 2024-09-16 16:55:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-16 16:55:13 +0200 |
commit | d9c5512878c28a4483116969e2ca77cce0131257 (patch) | |
tree | 8e21ae98e5f718c82aeb55980041b12b575a6ff7 /lib | |
parent | 6eefcdba0c4c239b027dfd7d6a2e9a5ef54e18b9 (diff) | |
parent | 13088b745a7b3cd0d81aae63c0c1ff9028cafbf6 (diff) | |
download | nextcloud-server-d9c5512878c28a4483116969e2ca77cce0131257.tar.gz nextcloud-server-d9c5512878c28a4483116969e2ca77cce0131257.zip |
Merge pull request #46140 from nextcloud/fix-nc-env-inclusion
fix(config): Add missing handling for `envCache` in `getKeys()`
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Config.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/private/Config.php b/lib/private/Config.php index 6823ab7027f..08f9b028856 100644 --- a/lib/private/Config.php +++ b/lib/private/Config.php @@ -49,7 +49,7 @@ class Config { * @return array an array of key names */ public function getKeys() { - return array_keys($this->cache); + return array_merge(array_keys($this->cache), array_keys($this->envCache)); } /** @@ -64,9 +64,8 @@ class Config { * @return mixed the value or $default */ public function getValue($key, $default = null) { - $envKey = self::ENV_PREFIX . $key; - if (isset($this->envCache[$envKey])) { - return $this->envCache[$envKey]; + if (isset($this->envCache[$key])) { + return $this->envCache[$key]; } if (isset($this->cache[$key])) { @@ -226,7 +225,16 @@ class Config { } } - $this->envCache = getenv(); + // grab any "NC_" environment variables + $envRaw = getenv(); + // only save environment variables prefixed with "NC_" in the cache + $envPrefixLen = strlen(self::ENV_PREFIX); + foreach ($envRaw as $rawEnvKey => $rawEnvValue) { + if (str_starts_with($rawEnvKey, self::ENV_PREFIX)) { + $realKey = substr($rawEnvKey, $envPrefixLen); + $this->envCache[$realKey] = $rawEnvValue; + } + } } /** |