diff --git a/src/App/Mode.php b/src/App/Mode.php index ca78ebd5bc..514df91c64 100644 --- a/src/App/Mode.php +++ b/src/App/Mode.php @@ -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); } diff --git a/src/Console/Cache.php b/src/Console/Cache.php index e4d1135335..c553716993 100644 --- a/src/Console/Cache.php +++ b/src/Console/Cache.php @@ -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'); } diff --git a/src/Console/Config.php b/src/Console/Config.php index 8df7c28f21..efb795360c 100644 --- a/src/Console/Config.php +++ b/src/Console/Config.php @@ -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)) { diff --git a/src/Console/Lock.php b/src/Console/Lock.php index 4e324691ca..0acede5df8 100644 --- a/src/Console/Lock.php +++ b/src/Console/Lock.php @@ -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'); } diff --git a/tests/functional/DependencyCheckTest.php b/tests/functional/DependencyCheckTest.php index 9bc7624d6a..a371ffea4c 100644 --- a/tests/functional/DependencyCheckTest.php +++ b/tests/functional/DependencyCheckTest.php @@ -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'); diff --git a/tests/src/App/ModeTest.php b/tests/src/App/ModeTest.php index 86a6c7763d..aecd2b1752 100644 --- a/tests/src/App/ModeTest.php +++ b/tests/src/App/ModeTest.php @@ -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)); }