Merge pull request #2227 from shlinkio/develop

Release 4.2.3
This commit is contained in:
Alejandro Celaya 2024-10-17 09:41:21 +02:00 committed by GitHub
commit 51de4b17c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 18 deletions

View file

@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
## [4.2.3] - 2024-10-17
### Added
* *Nothing*
### Changed
* *Nothing*
### Deprecated
* *Nothing*
### Removed
* *Nothing*
### Fixed
* [#2225](https://github.com/shlinkio/shlink/issues/2225) Fix regression introduced in v4.2.2, making config options with `null` value to be promoted as env vars with value `''`, instead of being skipped.
## [4.2.2] - 2024-10-14
### Added
* *Nothing*

View file

@ -45,7 +45,7 @@
"ramsey/uuid": "^4.7",
"shlinkio/doctrine-specification": "^2.1.1",
"shlinkio/shlink-common": "^6.3",
"shlinkio/shlink-config": "^3.2",
"shlinkio/shlink-config": "^3.2.1",
"shlinkio/shlink-event-dispatcher": "^4.1",
"shlinkio/shlink-importer": "^5.3.2",
"shlinkio/shlink-installer": "^9.2",

View file

@ -97,6 +97,23 @@ enum EnvVars: string
return env($this->value) ?? $this->loadFromFileEnv() ?? $this->defaultValue();
}
/**
* Checks if an equivalent environment variable exists with the `_FILE` suffix. If so, it loads its value as a file,
* reads it, and returns its contents.
* This is useful when loading Shlink with docker compose and using secrets.
* See https://docs.docker.com/compose/use-secrets/
*/
private function loadFromFileEnv(): string|int|bool|null
{
$file = env(sprintf('%s_FILE', $this->value));
if ($file === null || ! is_file($file)) {
return null;
}
$content = file_get_contents($file);
return $content ? parseEnvVar($content) : null;
}
private function defaultValue(): string|int|bool|null
{
return match ($this) {
@ -153,23 +170,6 @@ enum EnvVars: string
};
}
/**
* Checks if an equivalent environment variable exists with the `_FILE` suffix. If so, it loads its value as a file,
* reads it, and returns its contents.
* This is useful when loading Shlink with docker compose and using secrets.
* See https://docs.docker.com/compose/use-secrets/
*/
private function loadFromFileEnv(): string|int|bool|null
{
$file = env(sprintf('%s_FILE', $this->value));
if ($file === null || ! is_file($file)) {
return null;
}
$content = file_get_contents($file);
return $content ? parseEnvVar($content) : null;
}
public function existsInEnv(): bool
{
return $this->loadFromEnv() !== null;