]> git.mxchange.org Git - friendica.git/commitdiff
Bugfixing empty password setting
authorPhilipp Holzer <admin+github@philipp.info>
Mon, 10 Jun 2019 13:39:21 +0000 (15:39 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Mon, 10 Jun 2019 13:40:15 +0000 (15:40 +0200)
src/Core/Config/Cache/ConfigCache.php
tests/src/Core/Config/Cache/ConfigCacheTest.php

index 9aea367d978c9c1867ddca3795fe079bbde024fb..c3cec19e26ee940418fec6c954263bff7e5ed5d8 100644 (file)
@@ -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;
index 76ee26438fc8387f016bb5bb6e9c8472eb231c79..11845379d6b56dfb3c4e5c3142b037c69539b154 100644 (file)
@@ -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'));
+       }
 }