From 4666b18e5b23608905c3946c904364276c23b6ca Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 10 Jun 2019 15:39:21 +0200 Subject: [PATCH] Bugfixing empty password setting --- src/Core/Config/Cache/ConfigCache.php | 3 ++- tests/src/Core/Config/Cache/ConfigCacheTest.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Core/Config/Cache/ConfigCache.php b/src/Core/Config/Cache/ConfigCache.php index 9aea367d97..c3cec19e26 100644 --- a/src/Core/Config/Cache/ConfigCache.php +++ b/src/Core/Config/Cache/ConfigCache.php @@ -94,7 +94,8 @@ class ConfigCache implements IConfigCache, IPConfigCache } if ($this->hidePasswordOutput && - $key == 'password') { + $key == 'password' && + !empty($value)) { $this->config[$cat][$key] = new HiddenString($value); } else { $this->config[$cat][$key] = $value; diff --git a/tests/src/Core/Config/Cache/ConfigCacheTest.php b/tests/src/Core/Config/Cache/ConfigCacheTest.php index 76ee26438f..11845379d6 100644 --- a/tests/src/Core/Config/Cache/ConfigCacheTest.php +++ b/tests/src/Core/Config/Cache/ConfigCacheTest.php @@ -309,4 +309,20 @@ class ConfigCacheTest extends MockedTest $this->assertEquals('supersecure', print_r($configCache->get('database', 'password'), true)); $this->assertEquals('notsecured', print_r($configCache->get('database', 'username'), true)); } + + /** + * Test a empty password + */ + public function testEmptyPassword() + { + $confiCache = new ConfigCache([ + 'database' => [ + 'password' => '', + 'username' => '', + ] + ]); + + $this->assertEmpty($confiCache->get('database', 'password')); + $this->assertEmpty($confiCache->get('database', 'username')); + } } -- 2.20.1