summaryrefslogtreecommitdiff
path: root/classes/Config.php
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2025-05-02 13:37:08 +0300
committerAndrew Dolgov <fox@fakecake.org>2025-05-02 13:37:08 +0300
commit247efe3137fadf5d74ab254cf4c80957624abc90 (patch)
treec4de0075ea3c936c8581637e5779fd9e4fa5cf58 /classes/Config.php
parentaeca30cb0c6b26c569f66c5043690d5528fc481b (diff)
bring back cleanup of potentially sensitive environment variables but exclude CLI SAPI to prevent updater failures
Diffstat (limited to 'classes/Config.php')
-rw-r--r--classes/Config.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/classes/Config.php b/classes/Config.php
index c413317be..6e16f269b 100644
--- a/classes/Config.php
+++ b/classes/Config.php
@@ -275,6 +275,13 @@ class Config {
if (isset(self::_DEFAULTS[$const])) {
$override = getenv(self::_ENVVAR_PREFIX . $const);
+ // cleanup original env var after importing (unless it's a background process)
+ if (php_sapi_name() != "cli") {
+ putenv(self::_ENVVAR_PREFIX . $const . '=');
+ unset($_ENV[self::_ENVVAR_PREFIX . $const]);
+ unset($_SERVER[self::_ENVVAR_PREFIX . $const]);
+ }
+
list ($defval, $deftype) = self::_DEFAULTS[$const];
$this->params[$cvalue] = [ self::cast_to($override !== false ? $override : $defval, $deftype), $deftype ];
@@ -433,6 +440,13 @@ class Config {
private function _add(string $param, string $default, int $type_hint): void {
$override = getenv(self::_ENVVAR_PREFIX . $param);
+ // cleanup original env var after importing (unless it's a background process)
+ if (php_sapi_name() != "cli") {
+ putenv(self::_ENVVAR_PREFIX . $param . '=');
+ unset($_ENV[self::_ENVVAR_PREFIX . $param]);
+ unset($_SERVER[self::_ENVVAR_PREFIX . $param]);
+ }
+
$this->params[$param] = [ self::cast_to($override !== false ? $override : $default, $type_hint), $type_hint ];
}