Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Implemented feature to read config from environment variables #2100

Merged
merged 10 commits into from
Dec 3, 2021
13 changes: 13 additions & 0 deletions lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ public static function loadConfiguration() {
}
}

foreach (getenv() as $envkey => $value) {
// Replace all settings with their respective environment variable if available
$keyArray = explode('_', $envkey);
if($keyArray[0] === 'RSSBRIDGE') {
$header = strtolower($keyArray[1]);
$key = strtolower($keyArray[2]);
if($value === 'true' || $value === 'false') {
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
}
Configuration::$config[$header][$key] = $value;
}
}

if(!is_string(self::getConfig('system', 'timezone'))
|| !in_array(self::getConfig('system', 'timezone'), timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
self::reportConfigurationError('system', 'timezone');
Expand Down