Bugfixing DB/Installer

- default value with HiddenString
- Fixing checkDB during installation
This commit is contained in:
Philipp Holzer 2019-07-09 22:20:39 +02:00
parent 1f42f51351
commit ab7c6499ff
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
2 changed files with 8 additions and 13 deletions

View file

@ -22,7 +22,7 @@ return [
// pass (String) // pass (String)
// Database user password. Please don't use empty passwords. // Database user password. Please don't use empty passwords.
'password' => '', 'password' => new \ParagonIE\HiddenString\HiddenString(''),
// base (String) // base (String)
// Database name. // Database name.

View file

@ -7,8 +7,8 @@ namespace Friendica\Core;
use DOMDocument; use DOMDocument;
use Exception; use Exception;
use Friendica\Core\Config\Cache\IConfigCache; use Friendica\Core\Config\Cache\IConfigCache;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\Factory\DBFactory;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Logger\VoidLogger; use Friendica\Util\Logger\VoidLogger;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -600,23 +600,18 @@ class Installer
*/ */
public function checkDB(IConfigCache $configCache, Profiler $profiler) public function checkDB(IConfigCache $configCache, Profiler $profiler)
{ {
$dbhost = $configCache->get('database', 'hostname'); $database = DBFactory::init($configCache, $profiler, [], new VoidLogger());
$dbuser = $configCache->get('database', 'username');
$dbpass = $configCache->get('database', 'password');
$dbdata = $configCache->get('database', 'database');
if (!DBA::connect($configCache, $profiler, new VoidLogger(), $dbhost, $dbuser, $dbpass, $dbdata)) { if ($database->connected()) {
$this->addCheck(L10n::t('Could not connect to database.'), false, true, '');
return false;
}
if (DBA::connected()) {
if (DBStructure::existsTable('user')) { if (DBStructure::existsTable('user')) {
$this->addCheck(L10n::t('Database already in use.'), false, true, ''); $this->addCheck(L10n::t('Database already in use.'), false, true, '');
return false; return false;
} }
} else {
$this->addCheck(L10n::t('Could not connect to database.'), false, true, '');
return false;
} }
return true; return true;