From ab7c6499ffa7c6a592e55808636c77efa89ac9f5 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Tue, 9 Jul 2019 22:20:39 +0200 Subject: [PATCH] Bugfixing DB/Installer - default value with HiddenString - Fixing checkDB during installation --- config/defaults.config.php | 2 +- src/Core/Installer.php | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/config/defaults.config.php b/config/defaults.config.php index b4471af25c..fac08e9843 100644 --- a/config/defaults.config.php +++ b/config/defaults.config.php @@ -22,7 +22,7 @@ return [ // pass (String) // Database user password. Please don't use empty passwords. - 'password' => '', + 'password' => new \ParagonIE\HiddenString\HiddenString(''), // base (String) // Database name. diff --git a/src/Core/Installer.php b/src/Core/Installer.php index 046b34ea6f..f49dde4e56 100644 --- a/src/Core/Installer.php +++ b/src/Core/Installer.php @@ -7,8 +7,8 @@ namespace Friendica\Core; use DOMDocument; use Exception; use Friendica\Core\Config\Cache\IConfigCache; -use Friendica\Database\DBA; use Friendica\Database\DBStructure; +use Friendica\Factory\DBFactory; use Friendica\Object\Image; use Friendica\Util\Logger\VoidLogger; use Friendica\Util\Network; @@ -600,23 +600,18 @@ class Installer */ public function checkDB(IConfigCache $configCache, Profiler $profiler) { - $dbhost = $configCache->get('database', 'hostname'); - $dbuser = $configCache->get('database', 'username'); - $dbpass = $configCache->get('database', 'password'); - $dbdata = $configCache->get('database', 'database'); + $database = DBFactory::init($configCache, $profiler, [], new VoidLogger()); - if (!DBA::connect($configCache, $profiler, new VoidLogger(), $dbhost, $dbuser, $dbpass, $dbdata)) { - $this->addCheck(L10n::t('Could not connect to database.'), false, true, ''); - - return false; - } - - if (DBA::connected()) { + if ($database->connected()) { if (DBStructure::existsTable('user')) { $this->addCheck(L10n::t('Database already in use.'), false, true, ''); return false; } + } else { + $this->addCheck(L10n::t('Could not connect to database.'), false, true, ''); + + return false; } return true;