$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);
}
}
/**
- * 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);
}
/**
{
return $this->has(Mode::LOCALCONFIGPRESENT) &&
$this->has(Mode::DBAVAILABLE) &&
- $this->has(Mode::DBCONFIGAVAILABLE) &&
$this->has(Mode::MAINTENANCEDISABLED);
}
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);
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)) {
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();
self::assertFalse($mode->isNormal());
self::assertFalse($mode->isInstall());
- self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
self::assertFalse($mode->has(Mode::MAINTENANCEDISABLED));
}
$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));
}
$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));
}