mirror of
https://github.com/friendica/friendica
synced 2024-11-18 22:23:42 +00:00
Merge pull request #7358 from nupplaphil/bug/installer_db
Bugfixing DB/Installer (Simplify Config Part 1)
This commit is contained in:
commit
b56709d802
4 changed files with 13 additions and 16 deletions
|
@ -95,7 +95,7 @@ class ConfigCache implements IConfigCache, IPConfigCache
|
|||
|
||||
if ($this->hidePasswordOutput &&
|
||||
$key == 'password' &&
|
||||
!empty($value) && is_string($value)) {
|
||||
is_string($value)) {
|
||||
$this->config[$cat][$key] = new HiddenString((string) $value);
|
||||
} else {
|
||||
$this->config[$cat][$key] = $value;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -16,8 +16,6 @@ use org\bovigo\vfs\vfsStream;
|
|||
use org\bovigo\vfs\vfsStreamFile;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
class AutomaticInstallationConsoleTest extends ConsoleTest
|
||||
|
@ -43,6 +41,8 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
|
|||
|
||||
public function setUp()
|
||||
{
|
||||
$this->markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
|
||||
|
||||
parent::setUp();
|
||||
|
||||
if ($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Friendica\Test\src\Core\Config\Cache;
|
|||
|
||||
use Friendica\Core\Config\Cache\ConfigCache;
|
||||
use Friendica\Test\MockedTest;
|
||||
use ParagonIE\HiddenString\HiddenString;
|
||||
|
||||
class ConfigCacheTest extends MockedTest
|
||||
{
|
||||
|
@ -322,7 +323,8 @@ class ConfigCacheTest extends MockedTest
|
|||
]
|
||||
]);
|
||||
|
||||
$this->assertEmpty($configCache->get('database', 'password'));
|
||||
$this->assertNotEmpty($configCache->get('database', 'password'));
|
||||
$this->assertInstanceOf(HiddenString::class, $configCache->get('database', 'password'));
|
||||
$this->assertEmpty($configCache->get('database', 'username'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue