]> git.mxchange.org Git - friendica.git/commitdiff
Remove deprecated Mode::DBCONFIGAVAILABLE
authorPhilipp <admin@philipp.info>
Wed, 28 Dec 2022 01:57:57 +0000 (02:57 +0100)
committerPhilipp <admin@philipp.info>
Tue, 3 Jan 2023 13:22:04 +0000 (14:22 +0100)
src/App/Mode.php
src/Console/Cache.php
src/Console/Config.php
src/Console/Lock.php
tests/functional/DependencyCheckTest.php
tests/src/App/ModeTest.php

index ca78ebd5bc690ede8bd5625db6d19231a6d88a72..514df91c649d7cc53e1199ea3d2cfce7698ff2b4 100644 (file)
@@ -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);
        }
 
index e4d1135335d06ef86c54fc2a6e18813eb88a9bd9..c5537169938c6042a16c91a64546d1ced3327d7c 100644 (file)
@@ -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');
                }
 
index 8df7c28f21f19d61ba4a91a3aa1ea407023105f2..efb795360cac7c9ba5c882c7ec3480c256b936aa 100644 (file)
@@ -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)) {
index 4e324691caef4d3a5ae8d6a3315f88ff527636e0..0acede5df890b63b52472d1cb5603746587588aa 100644 (file)
@@ -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');
                }
 
index 9bc7624d6acb2726bd3b4655344f3b8aebe471d6..a371ffea4ca7c4e881643bcd744a62f040115b1c 100644 (file)
@@ -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');
index 86a6c7763d04cdc3cf786398751c426be4ccc988..aecd2b17526f37200008ae925a575273a4ed1481 100644 (file)
@@ -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));
        }