From 4568a197e70e8a1fa2670a25c3c7bd50f35ed04e Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 13 Sep 2021 11:53:12 +0300 Subject: [PATCH] Fixed excessive `security.yaml` file creation [#3432] --- CHANGELOG.md | 1 + system/src/Grav/Common/Config/Setup.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8be0784d8..130dae61d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ 3. [](#bugfix) * Fixed escaping in PageIndex::getLevelListing() * Fixed validation of `number` type [#3433](https://github.com/getgrav/grav/issues/3433) + * Fixed excessive `security.yaml` file creation [#3432](https://github.com/getgrav/grav/issues/3432) # v1.7.20 ## 09/01/2021 diff --git a/system/src/Grav/Common/Config/Setup.php b/system/src/Grav/Common/Config/Setup.php index 83a276395..88fde50d8 100644 --- a/system/src/Grav/Common/Config/Setup.php +++ b/system/src/Grav/Common/Config/Setup.php @@ -400,8 +400,12 @@ class Setup extends Data $this->initializeLocator($locator); } - // Create security.yaml if it doesn't exist. - $filename = $locator->findResource(static::$securityFile, true, true); + // Create security.yaml salt if it doesn't exist into existing configuration environment if possible. + $securityFile = basename(static::$securityFile); + $securityFolder = substr(static::$securityFile, 0, -\strlen($securityFile)); + $securityFolder = $locator->findResource($securityFolder, true) ?: $locator->findResource($securityFolder, true, true); + $filename = " {$securityFolder}/{$securityFile}"; + $security_file = CompiledYamlFile::instance($filename); $security_content = (array)$security_file->content();