mirror of
https://github.com/friendica/friendica
synced 2024-12-23 00:00:21 +00:00
Remove deprecated Mode::DBCONFIGAVAILABLE
This commit is contained in:
parent
1e574d5383
commit
10f3de0aa2
6 changed files with 5 additions and 55 deletions
|
@ -149,16 +149,7 @@ class Mode
|
|||
|
||||
$mode |= Mode::DBAVAILABLE;
|
||||
|
||||
if ($database->fetchFirst("SHOW TABLES LIKE 'config'") === false) {
|
||||
return new Mode($mode);
|
||||
}
|
||||
|
||||
$mode |= Mode::DBCONFIGAVAILABLE;
|
||||
|
||||
if (!empty($configCache->get('system', 'maintenance')) ||
|
||||
// Don't use Config or Configuration here because we're possibly BEFORE initializing the Configuration,
|
||||
// so this could lead to a dependency circle
|
||||
!empty($database->selectFirst('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])['v'])) {
|
||||
if (!empty($configCache->get('system', 'maintenance'))) {
|
||||
return new Mode($mode);
|
||||
}
|
||||
|
||||
|
@ -232,14 +223,14 @@ class Mode
|
|||
}
|
||||
|
||||
/**
|
||||
* Install mode is when the local config file is missing or the DB schema hasn't been installed yet.
|
||||
* Install mode is when the local config file is missing or the database isn't available.
|
||||
*
|
||||
* @return bool Whether installation mode is active (local/database configuration files present or not)
|
||||
*/
|
||||
public function isInstall(): bool
|
||||
{
|
||||
return !$this->has(Mode::LOCALCONFIGPRESENT) ||
|
||||
!$this->has(MODE::DBCONFIGAVAILABLE);
|
||||
!$this->has(MODE::DBAVAILABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -251,7 +242,6 @@ class Mode
|
|||
{
|
||||
return $this->has(Mode::LOCALCONFIGPRESENT) &&
|
||||
$this->has(Mode::DBAVAILABLE) &&
|
||||
$this->has(Mode::DBCONFIGAVAILABLE) &&
|
||||
$this->has(Mode::MAINTENANCEDISABLED);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ HELP;
|
|||
$this->out('Options: ' . var_export($this->options, true));
|
||||
}
|
||||
|
||||
if (!$this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!$this->appMode->has(App\Mode::DBAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, database cache won\'t be available');
|
||||
}
|
||||
|
||||
|
|
|
@ -115,10 +115,6 @@ HELP;
|
|||
throw new CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if (!$this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, showing file config only');
|
||||
}
|
||||
|
||||
if (count($this->args) == 3) {
|
||||
$cat = $this->getArgument(0);
|
||||
$key = $this->getArgument(1);
|
||||
|
@ -180,10 +176,6 @@ HELP;
|
|||
if (count($this->args) == 0) {
|
||||
$this->config->reload();
|
||||
|
||||
if ($this->config->get('system', 'config_adapter') == 'jit' && $this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
$this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
|
||||
}
|
||||
|
||||
$config = $this->config->getCache()->getAll();
|
||||
foreach ($config as $cat => $section) {
|
||||
if (is_array($section)) {
|
||||
|
|
|
@ -93,7 +93,7 @@ HELP;
|
|||
$this->out('Options: ' . var_export($this->options, true));
|
||||
}
|
||||
|
||||
if (!$this->appMode->has(App\Mode::DBCONFIGAVAILABLE)) {
|
||||
if (!$this->appMode->has(App\Mode::DBAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, database cache won\'t be available');
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,6 @@ class DependencyCheckTest extends TestCase
|
|||
|
||||
self::assertTrue($mode->has(App\Mode::LOCALCONFIGPRESENT), 'No local config present');
|
||||
self::assertTrue($mode->has(App\Mode::DBAVAILABLE), 'Database is not available');
|
||||
self::assertTrue($mode->has(App\Mode::DBCONFIGAVAILABLE), 'Database config is not available');
|
||||
self::assertTrue($mode->has(App\Mode::MAINTENANCEDISABLED), 'In maintenance mode');
|
||||
|
||||
self::assertTrue($mode->isNormal(), 'Not in normal mode');
|
||||
|
|
|
@ -102,29 +102,11 @@ class ModeTest extends MockedTest
|
|||
self::assertFalse($mode->has(Mode::DBAVAILABLE));
|
||||
}
|
||||
|
||||
public function testWithoutDatabaseSetup()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
|
||||
$this->databaseMock->shouldReceive('fetchFirst')
|
||||
->with('SHOW TABLES LIKE \'config\'')->andReturn(false)->once();
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertFalse($mode->isNormal());
|
||||
self::assertTrue($mode->isInstall());
|
||||
|
||||
self::assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
|
||||
}
|
||||
|
||||
public function testWithMaintenanceMode()
|
||||
{
|
||||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
|
||||
$this->databaseMock->shouldReceive('fetchFirst')
|
||||
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
|
||||
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
|
||||
->andReturn(true)->once();
|
||||
|
||||
|
@ -133,7 +115,6 @@ class ModeTest extends MockedTest
|
|||
self::assertFalse($mode->isNormal());
|
||||
self::assertFalse($mode->isInstall());
|
||||
|
||||
self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
|
||||
self::assertFalse($mode->has(Mode::MAINTENANCEDISABLED));
|
||||
}
|
||||
|
||||
|
@ -142,20 +123,14 @@ class ModeTest extends MockedTest
|
|||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
|
||||
$this->databaseMock->shouldReceive('fetchFirst')
|
||||
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
|
||||
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
|
||||
->andReturn(false)->once();
|
||||
$this->databaseMock->shouldReceive('selectFirst')
|
||||
->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
|
||||
->andReturn(['v' => null])->once();
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertTrue($mode->isNormal());
|
||||
self::assertFalse($mode->isInstall());
|
||||
|
||||
self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
|
||||
self::assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
|
||||
}
|
||||
|
||||
|
@ -167,20 +142,14 @@ class ModeTest extends MockedTest
|
|||
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
|
||||
|
||||
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
|
||||
$this->databaseMock->shouldReceive('fetchFirst')
|
||||
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
|
||||
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
|
||||
->andReturn(false)->once();
|
||||
$this->databaseMock->shouldReceive('selectFirst')
|
||||
->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
|
||||
->andReturn(['v' => '0'])->once();
|
||||
|
||||
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
|
||||
|
||||
self::assertTrue($mode->isNormal());
|
||||
self::assertFalse($mode->isInstall());
|
||||
|
||||
self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
|
||||
self::assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue