From cc6c910d9b4b960d9cd4a307c1c52b143b6fb428 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 20 Jan 2026 23:06:10 +0000 Subject: [PATCH 01/11] Remove setGlobalConfig() Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 9 --------- psalm-baseline.xml | 3 --- tests/unit/AbstractTestCase.php | 9 --------- tests/unit/Advisory/AdvisorTest.php | 2 -- tests/unit/Config/DescriptionTest.php | 7 ------- tests/unit/Config/FormDisplayTest.php | 2 -- tests/unit/Config/FormTest.php | 2 -- tests/unit/Config/Forms/FormListTest.php | 7 ------- tests/unit/Config/PageSettingsTest.php | 2 -- tests/unit/Config/ServerConfigChecksTest.php | 2 -- tests/unit/Controllers/Server/BinlogControllerTest.php | 2 -- .../Controllers/Server/CollationsControllerTest.php | 2 -- .../Controllers/Server/DatabasesControllerTest.php | 2 -- .../unit/Controllers/Server/EnginesControllerTest.php | 2 -- .../unit/Controllers/Server/PluginsControllerTest.php | 2 -- .../Controllers/Server/ShowEngineControllerTest.php | 2 -- .../Server/Status/AdvisorControllerTest.php | 2 -- .../Server/Status/Monitor/GeneralLogControllerTest.php | 2 -- .../Server/Status/Monitor/LogVarsControllerTest.php | 2 -- .../Server/Status/Monitor/SlowLogControllerTest.php | 2 -- .../Server/Status/MonitorControllerTest.php | 2 -- .../Server/Status/Processes/RefreshControllerTest.php | 2 -- .../Server/Status/ProcessesControllerTest.php | 2 -- .../Server/Status/QueriesControllerTest.php | 2 -- .../Controllers/Server/Status/StatusControllerTest.php | 2 -- .../Server/Status/VariablesControllerTest.php | 2 -- .../Controllers/Server/VariablesControllerTest.php | 2 -- .../Transformation/OverviewControllerTest.php | 2 -- tests/unit/Database/CentralColumnsTest.php | 2 -- tests/unit/Database/EventsTest.php | 2 -- tests/unit/Database/RoutinesTest.php | 2 -- tests/unit/Display/ResultsTest.php | 2 -- tests/unit/Export/OptionsTest.php | 2 -- tests/unit/FooterTest.php | 2 -- tests/unit/HeaderTest.php | 2 -- tests/unit/InsertEditTest.php | 2 -- tests/unit/Navigation/NavigationTreeTest.php | 2 -- tests/unit/PdfTest.php | 10 ---------- tests/unit/Plugins/Auth/AuthenticationConfigTest.php | 2 -- tests/unit/Plugins/Auth/AuthenticationCookieTest.php | 2 -- tests/unit/Plugins/Auth/AuthenticationHttpTest.php | 2 -- tests/unit/Plugins/Auth/AuthenticationSignonTest.php | 2 -- tests/unit/Setup/ConfigGeneratorTest.php | 2 -- tests/unit/Theme/ThemeManagerTest.php | 2 -- tests/unit/Theme/ThemeTest.php | 2 -- tests/unit/Triggers/TriggersTest.php | 2 -- 46 files changed, 125 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 391a0798c1..5d77bcf8b2 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -13809,15 +13809,6 @@ parameters: count: 1 path: tests/test_data/config.inc.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: - Use dependency injection instead\.$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: tests/unit/AbstractTestCase.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\: diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7ab11575f7..c353ba0f11 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -8792,9 +8792,6 @@ - - - diff --git a/tests/unit/AbstractTestCase.php b/tests/unit/AbstractTestCase.php index d719c81dcb..563bf09916 100644 --- a/tests/unit/AbstractTestCase.php +++ b/tests/unit/AbstractTestCase.php @@ -65,7 +65,6 @@ abstract class AbstractTestCase extends TestCase ExportSql::$noConstraintsComments = false; // Config before DBI - $this->setGlobalConfig(); Cache::purge(); Tracker::disable(); @@ -93,14 +92,6 @@ abstract class AbstractTestCase extends TestCase return $config; } - protected function setGlobalConfig(): void - { - Config::$instance = null; - $config = Config::getInstance(); - $config->loadFromFile(); - $config->set('environment', 'development'); - } - protected function setLanguage(string $code = 'en'): void { Current::$lang = $code; diff --git a/tests/unit/Advisory/AdvisorTest.php b/tests/unit/Advisory/AdvisorTest.php index e24b4943da..3ce928fb95 100644 --- a/tests/unit/Advisory/AdvisorTest.php +++ b/tests/unit/Advisory/AdvisorTest.php @@ -20,8 +20,6 @@ class AdvisorTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); } diff --git a/tests/unit/Config/DescriptionTest.php b/tests/unit/Config/DescriptionTest.php index 7736dd3b79..d39e35bbf5 100644 --- a/tests/unit/Config/DescriptionTest.php +++ b/tests/unit/Config/DescriptionTest.php @@ -20,13 +20,6 @@ use function in_array; #[RunTestsInSeparateProcesses] class DescriptionTest extends AbstractTestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->setGlobalConfig(); - } - /** * @param string $item item * @param string $type type diff --git a/tests/unit/Config/FormDisplayTest.php b/tests/unit/Config/FormDisplayTest.php index 7382bc3ba9..124526c9e5 100644 --- a/tests/unit/Config/FormDisplayTest.php +++ b/tests/unit/Config/FormDisplayTest.php @@ -31,8 +31,6 @@ class FormDisplayTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - Current::$server = 2; $this->object = new FormDisplay(new ConfigFile()); Form::resetGroupCounter(); diff --git a/tests/unit/Config/FormTest.php b/tests/unit/Config/FormTest.php index 6a29c82716..a1cdf2ced8 100644 --- a/tests/unit/Config/FormTest.php +++ b/tests/unit/Config/FormTest.php @@ -28,8 +28,6 @@ class FormTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->object = new Form( 'pma_form_name', ['pma_form1', 'pma_form2'], diff --git a/tests/unit/Config/Forms/FormListTest.php b/tests/unit/Config/Forms/FormListTest.php index 4689926229..e779cbd8fe 100644 --- a/tests/unit/Config/Forms/FormListTest.php +++ b/tests/unit/Config/Forms/FormListTest.php @@ -24,13 +24,6 @@ use PHPUnit\Framework\Attributes\DataProvider; #[CoversClass(UserFormList::class)] class FormListTest extends AbstractTestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->setGlobalConfig(); - } - /** * Tests for preferences forms. * diff --git a/tests/unit/Config/PageSettingsTest.php b/tests/unit/Config/PageSettingsTest.php index 56af0b79d1..57e348a3e8 100644 --- a/tests/unit/Config/PageSettingsTest.php +++ b/tests/unit/Config/PageSettingsTest.php @@ -30,8 +30,6 @@ class PageSettingsTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); Current::$database = 'db'; Current::$table = ''; diff --git a/tests/unit/Config/ServerConfigChecksTest.php b/tests/unit/Config/ServerConfigChecksTest.php index 8462e628bc..5419a9c853 100644 --- a/tests/unit/Config/ServerConfigChecksTest.php +++ b/tests/unit/Config/ServerConfigChecksTest.php @@ -30,8 +30,6 @@ class ServerConfigChecksTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->configFile = new ConfigFile(); $reflection = new ReflectionProperty(ConfigFile::class, 'id'); diff --git a/tests/unit/Controllers/Server/BinlogControllerTest.php b/tests/unit/Controllers/Server/BinlogControllerTest.php index be1e5bd2c2..efc5cfd689 100644 --- a/tests/unit/Controllers/Server/BinlogControllerTest.php +++ b/tests/unit/Controllers/Server/BinlogControllerTest.php @@ -27,8 +27,6 @@ class BinlogControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/CollationsControllerTest.php b/tests/unit/Controllers/Server/CollationsControllerTest.php index f55203f813..b701928aff 100644 --- a/tests/unit/Controllers/Server/CollationsControllerTest.php +++ b/tests/unit/Controllers/Server/CollationsControllerTest.php @@ -28,8 +28,6 @@ class CollationsControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/DatabasesControllerTest.php b/tests/unit/Controllers/Server/DatabasesControllerTest.php index b3fb1e66ae..6287687a4c 100644 --- a/tests/unit/Controllers/Server/DatabasesControllerTest.php +++ b/tests/unit/Controllers/Server/DatabasesControllerTest.php @@ -28,8 +28,6 @@ class DatabasesControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/EnginesControllerTest.php b/tests/unit/Controllers/Server/EnginesControllerTest.php index 4e578727cf..c49a8105e1 100644 --- a/tests/unit/Controllers/Server/EnginesControllerTest.php +++ b/tests/unit/Controllers/Server/EnginesControllerTest.php @@ -28,8 +28,6 @@ class EnginesControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/PluginsControllerTest.php b/tests/unit/Controllers/Server/PluginsControllerTest.php index 1fa2a9d69a..de312d09df 100644 --- a/tests/unit/Controllers/Server/PluginsControllerTest.php +++ b/tests/unit/Controllers/Server/PluginsControllerTest.php @@ -30,8 +30,6 @@ class PluginsControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/ShowEngineControllerTest.php b/tests/unit/Controllers/Server/ShowEngineControllerTest.php index d136e9d2a7..5ee9f06319 100644 --- a/tests/unit/Controllers/Server/ShowEngineControllerTest.php +++ b/tests/unit/Controllers/Server/ShowEngineControllerTest.php @@ -30,8 +30,6 @@ class ShowEngineControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php b/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php index 959e2cbd9a..85fdcd66e3 100644 --- a/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php +++ b/tests/unit/Controllers/Server/Status/AdvisorControllerTest.php @@ -29,8 +29,6 @@ class AdvisorControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); $config = Config::getInstance(); diff --git a/tests/unit/Controllers/Server/Status/Monitor/GeneralLogControllerTest.php b/tests/unit/Controllers/Server/Status/Monitor/GeneralLogControllerTest.php index a9b80adae0..db5fb584be 100644 --- a/tests/unit/Controllers/Server/Status/Monitor/GeneralLogControllerTest.php +++ b/tests/unit/Controllers/Server/Status/Monitor/GeneralLogControllerTest.php @@ -30,8 +30,6 @@ class GeneralLogControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/Monitor/LogVarsControllerTest.php b/tests/unit/Controllers/Server/Status/Monitor/LogVarsControllerTest.php index 13e0b5cc06..06a7a7a269 100644 --- a/tests/unit/Controllers/Server/Status/Monitor/LogVarsControllerTest.php +++ b/tests/unit/Controllers/Server/Status/Monitor/LogVarsControllerTest.php @@ -30,8 +30,6 @@ class LogVarsControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/Monitor/SlowLogControllerTest.php b/tests/unit/Controllers/Server/Status/Monitor/SlowLogControllerTest.php index 2ed1bde1e2..8dca32598a 100644 --- a/tests/unit/Controllers/Server/Status/Monitor/SlowLogControllerTest.php +++ b/tests/unit/Controllers/Server/Status/Monitor/SlowLogControllerTest.php @@ -30,8 +30,6 @@ class SlowLogControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/MonitorControllerTest.php b/tests/unit/Controllers/Server/Status/MonitorControllerTest.php index 68bcd7eefb..46e7ecb340 100644 --- a/tests/unit/Controllers/Server/Status/MonitorControllerTest.php +++ b/tests/unit/Controllers/Server/Status/MonitorControllerTest.php @@ -31,8 +31,6 @@ class MonitorControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/Processes/RefreshControllerTest.php b/tests/unit/Controllers/Server/Status/Processes/RefreshControllerTest.php index 74ede6e831..1d17a16fff 100644 --- a/tests/unit/Controllers/Server/Status/Processes/RefreshControllerTest.php +++ b/tests/unit/Controllers/Server/Status/Processes/RefreshControllerTest.php @@ -31,8 +31,6 @@ class RefreshControllerTest extends AbstractTestCase DatabaseInterface::$instance = $this->createDatabaseInterface(); - $this->setGlobalConfig(); - Current::$database = 'db'; Current::$table = 'table'; $config = Config::getInstance(); diff --git a/tests/unit/Controllers/Server/Status/ProcessesControllerTest.php b/tests/unit/Controllers/Server/Status/ProcessesControllerTest.php index 26ca5ebfa1..ae4726c89f 100644 --- a/tests/unit/Controllers/Server/Status/ProcessesControllerTest.php +++ b/tests/unit/Controllers/Server/Status/ProcessesControllerTest.php @@ -31,8 +31,6 @@ class ProcessesControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/QueriesControllerTest.php b/tests/unit/Controllers/Server/Status/QueriesControllerTest.php index 3814a998a1..1a6482c5ed 100644 --- a/tests/unit/Controllers/Server/Status/QueriesControllerTest.php +++ b/tests/unit/Controllers/Server/Status/QueriesControllerTest.php @@ -34,8 +34,6 @@ class QueriesControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/StatusControllerTest.php b/tests/unit/Controllers/Server/Status/StatusControllerTest.php index d0762c9ec5..25c52599ec 100644 --- a/tests/unit/Controllers/Server/Status/StatusControllerTest.php +++ b/tests/unit/Controllers/Server/Status/StatusControllerTest.php @@ -29,8 +29,6 @@ class StatusControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/Status/VariablesControllerTest.php b/tests/unit/Controllers/Server/Status/VariablesControllerTest.php index 9d62da0cda..886e878a17 100644 --- a/tests/unit/Controllers/Server/Status/VariablesControllerTest.php +++ b/tests/unit/Controllers/Server/Status/VariablesControllerTest.php @@ -29,8 +29,6 @@ class VariablesControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Controllers/Server/VariablesControllerTest.php b/tests/unit/Controllers/Server/VariablesControllerTest.php index 083c6cc779..c5297c903b 100644 --- a/tests/unit/Controllers/Server/VariablesControllerTest.php +++ b/tests/unit/Controllers/Server/VariablesControllerTest.php @@ -35,8 +35,6 @@ class VariablesControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->setLanguage(); Current::$database = 'db'; diff --git a/tests/unit/Controllers/Transformation/OverviewControllerTest.php b/tests/unit/Controllers/Transformation/OverviewControllerTest.php index 4d21d3ca19..dc01b38168 100644 --- a/tests/unit/Controllers/Transformation/OverviewControllerTest.php +++ b/tests/unit/Controllers/Transformation/OverviewControllerTest.php @@ -25,8 +25,6 @@ class OverviewControllerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - Current::$database = 'db'; Current::$table = 'table'; } diff --git a/tests/unit/Database/CentralColumnsTest.php b/tests/unit/Database/CentralColumnsTest.php index 831c911253..d74eba1a51 100644 --- a/tests/unit/Database/CentralColumnsTest.php +++ b/tests/unit/Database/CentralColumnsTest.php @@ -103,8 +103,6 @@ class CentralColumnsTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $config = Config::getInstance(); $config->selectedServer['user'] = 'pma_user'; $config->selectedServer['DisableIS'] = true; diff --git a/tests/unit/Database/EventsTest.php b/tests/unit/Database/EventsTest.php index 3677f30ead..a1576ec716 100644 --- a/tests/unit/Database/EventsTest.php +++ b/tests/unit/Database/EventsTest.php @@ -24,8 +24,6 @@ class EventsTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->setLanguage(); DatabaseInterface::$instance = $this->createDatabaseInterface(); diff --git a/tests/unit/Database/RoutinesTest.php b/tests/unit/Database/RoutinesTest.php index 8b08d3b9ab..ffd03868f5 100644 --- a/tests/unit/Database/RoutinesTest.php +++ b/tests/unit/Database/RoutinesTest.php @@ -28,8 +28,6 @@ class RoutinesTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->setLanguage(); DatabaseInterface::$instance = $this->createDatabaseInterface(); diff --git a/tests/unit/Display/ResultsTest.php b/tests/unit/Display/ResultsTest.php index 54eef12c64..1c473a4df9 100644 --- a/tests/unit/Display/ResultsTest.php +++ b/tests/unit/Display/ResultsTest.php @@ -73,8 +73,6 @@ class ResultsTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Export/OptionsTest.php b/tests/unit/Export/OptionsTest.php index 71ccbc6cce..883842cc45 100644 --- a/tests/unit/Export/OptionsTest.php +++ b/tests/unit/Export/OptionsTest.php @@ -35,8 +35,6 @@ class OptionsTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - $dbi = $this->createDatabaseInterface(); DatabaseInterface::$instance = $dbi; diff --git a/tests/unit/FooterTest.php b/tests/unit/FooterTest.php index d0a354cec5..0d8a093509 100644 --- a/tests/unit/FooterTest.php +++ b/tests/unit/FooterTest.php @@ -34,8 +34,6 @@ class FooterTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); $_SERVER['SCRIPT_NAME'] = 'index.php'; Current::$database = ''; diff --git a/tests/unit/HeaderTest.php b/tests/unit/HeaderTest.php index 677f2d3a87..6a7429ff69 100644 --- a/tests/unit/HeaderTest.php +++ b/tests/unit/HeaderTest.php @@ -44,8 +44,6 @@ class HeaderTest extends AbstractTestCase Current::$database = 'db'; Current::$table = ''; - $this->setGlobalConfig(); - $config = Config::getInstance(); $config->settings['Servers'] = []; $config->selectedServer['DisableIS'] = false; diff --git a/tests/unit/InsertEditTest.php b/tests/unit/InsertEditTest.php index 87d0f4cc44..3de6b4e706 100644 --- a/tests/unit/InsertEditTest.php +++ b/tests/unit/InsertEditTest.php @@ -65,8 +65,6 @@ class InsertEditTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - $this->dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; diff --git a/tests/unit/Navigation/NavigationTreeTest.php b/tests/unit/Navigation/NavigationTreeTest.php index baa4424a3b..999f7bba14 100644 --- a/tests/unit/Navigation/NavigationTreeTest.php +++ b/tests/unit/Navigation/NavigationTreeTest.php @@ -28,8 +28,6 @@ class NavigationTreeTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - $dbi = $this->createDatabaseInterface(); DatabaseInterface::$instance = $dbi; $config = Config::getInstance(); diff --git a/tests/unit/PdfTest.php b/tests/unit/PdfTest.php index 182a83139b..fb0981dbcd 100644 --- a/tests/unit/PdfTest.php +++ b/tests/unit/PdfTest.php @@ -12,16 +12,6 @@ use PHPUnit\Framework\Attributes\Large; #[Large] class PdfTest extends AbstractTestCase { - /** - * SetUp for test cases - */ - protected function setUp(): void - { - parent::setUp(); - - $this->setGlobalConfig(); - } - /** * Test for Pdf::getPDFData */ diff --git a/tests/unit/Plugins/Auth/AuthenticationConfigTest.php b/tests/unit/Plugins/Auth/AuthenticationConfigTest.php index 1e6788958d..a01fa8f1c8 100644 --- a/tests/unit/Plugins/Auth/AuthenticationConfigTest.php +++ b/tests/unit/Plugins/Auth/AuthenticationConfigTest.php @@ -32,8 +32,6 @@ class AuthenticationConfigTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); Current::$server = 2; Current::$database = 'db'; diff --git a/tests/unit/Plugins/Auth/AuthenticationCookieTest.php b/tests/unit/Plugins/Auth/AuthenticationCookieTest.php index 75e104537c..96253b57d9 100644 --- a/tests/unit/Plugins/Auth/AuthenticationCookieTest.php +++ b/tests/unit/Plugins/Auth/AuthenticationCookieTest.php @@ -52,8 +52,6 @@ class AuthenticationCookieTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); Current::$database = 'db'; Current::$table = 'table'; diff --git a/tests/unit/Plugins/Auth/AuthenticationHttpTest.php b/tests/unit/Plugins/Auth/AuthenticationHttpTest.php index 0aa53ea2da..ad1a758ad8 100644 --- a/tests/unit/Plugins/Auth/AuthenticationHttpTest.php +++ b/tests/unit/Plugins/Auth/AuthenticationHttpTest.php @@ -33,8 +33,6 @@ class AuthenticationHttpTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); Config::getInstance()->settings['Servers'] = []; Current::$database = 'db'; diff --git a/tests/unit/Plugins/Auth/AuthenticationSignonTest.php b/tests/unit/Plugins/Auth/AuthenticationSignonTest.php index fe05587f00..7b03943e3a 100644 --- a/tests/unit/Plugins/Auth/AuthenticationSignonTest.php +++ b/tests/unit/Plugins/Auth/AuthenticationSignonTest.php @@ -37,8 +37,6 @@ class AuthenticationSignonTest extends AbstractTestCase $this->setLanguage(); - $this->setGlobalConfig(); - DatabaseInterface::$instance = $this->createDatabaseInterface(); Current::$database = 'db'; Current::$table = 'table'; diff --git a/tests/unit/Setup/ConfigGeneratorTest.php b/tests/unit/Setup/ConfigGeneratorTest.php index 27d499f64d..1e631a76a6 100644 --- a/tests/unit/Setup/ConfigGeneratorTest.php +++ b/tests/unit/Setup/ConfigGeneratorTest.php @@ -31,8 +31,6 @@ class ConfigGeneratorTest extends AbstractTestCase { unset($_SESSION['eol']); - $this->setGlobalConfig(); - Current::$server = 2; $cf = new ConfigFile(); $_SESSION['ConfigFile2'] = ['a', 'b', 'c']; diff --git a/tests/unit/Theme/ThemeManagerTest.php b/tests/unit/Theme/ThemeManagerTest.php index ddaf113572..59804fe991 100644 --- a/tests/unit/Theme/ThemeManagerTest.php +++ b/tests/unit/Theme/ThemeManagerTest.php @@ -19,8 +19,6 @@ class ThemeManagerTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - Current::$server = 99; } diff --git a/tests/unit/Theme/ThemeTest.php b/tests/unit/Theme/ThemeTest.php index 2b3e26da07..3b1374586a 100644 --- a/tests/unit/Theme/ThemeTest.php +++ b/tests/unit/Theme/ThemeTest.php @@ -32,8 +32,6 @@ class ThemeTest extends AbstractTestCase parent::setUp(); $this->object = new Theme(); - - $this->setGlobalConfig(); } /** diff --git a/tests/unit/Triggers/TriggersTest.php b/tests/unit/Triggers/TriggersTest.php index 77ab0b3023..126e703d5d 100644 --- a/tests/unit/Triggers/TriggersTest.php +++ b/tests/unit/Triggers/TriggersTest.php @@ -26,8 +26,6 @@ class TriggersTest extends AbstractTestCase { parent::setUp(); - $this->setGlobalConfig(); - $this->setLanguage(); DatabaseInterface::$instance = $this->createDatabaseInterface(); From 244bde1a9ab28690c2f495eec6e8c810f3df7e2b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 20 Jan 2026 23:11:02 +0000 Subject: [PATCH 02/11] Move createConfig to ConfigTest Signed-off-by: Kamil Tekiela --- tests/unit/AbstractTestCase.php | 8 -------- tests/unit/Config/FormDisplayTemplateTest.php | 2 +- tests/unit/ConfigTest.php | 8 ++++++++ tests/unit/Controllers/Table/AddFieldControllerTest.php | 2 +- tests/unit/Controllers/Table/CreateControllerTest.php | 2 +- .../Table/Maintenance/AnalyzeControllerTest.php | 3 ++- .../Controllers/Table/Maintenance/CheckControllerTest.php | 3 ++- .../Table/Maintenance/ChecksumControllerTest.php | 3 ++- .../Table/Maintenance/OptimizeControllerTest.php | 3 ++- .../Table/Maintenance/RepairControllerTest.php | 3 ++- 10 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/unit/AbstractTestCase.php b/tests/unit/AbstractTestCase.php index 563bf09916..5cea5832e1 100644 --- a/tests/unit/AbstractTestCase.php +++ b/tests/unit/AbstractTestCase.php @@ -84,14 +84,6 @@ abstract class AbstractTestCase extends TestCase return new DbiDummy(); } - protected function createConfig(): Config - { - $config = new Config(); - $config->loadFromFile(); - - return $config; - } - protected function setLanguage(string $code = 'en'): void { Current::$lang = $code; diff --git a/tests/unit/Config/FormDisplayTemplateTest.php b/tests/unit/Config/FormDisplayTemplateTest.php index 6831b0a989..c8c16e1317 100644 --- a/tests/unit/Config/FormDisplayTemplateTest.php +++ b/tests/unit/Config/FormDisplayTemplateTest.php @@ -25,7 +25,7 @@ class FormDisplayTemplateTest extends AbstractTestCase $this->setLanguage(); - $this->config = $this->createConfig(); + $this->config = new Config(); $this->formDisplayTemplate = new FormDisplayTemplate($this->config); } diff --git a/tests/unit/ConfigTest.php b/tests/unit/ConfigTest.php index 08b455e3bb..3523206a82 100644 --- a/tests/unit/ConfigTest.php +++ b/tests/unit/ConfigTest.php @@ -62,6 +62,14 @@ class ConfigTest extends AbstractTestCase $this->permTestObj->loadFromFile(ROOT_PATH . 'config.sample.inc.php'); } + protected function createConfig(): Config + { + $config = new Config(); + $config->loadFromFile(); + + return $config; + } + /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. diff --git a/tests/unit/Controllers/Table/AddFieldControllerTest.php b/tests/unit/Controllers/Table/AddFieldControllerTest.php index 2880839595..201a0bcb71 100644 --- a/tests/unit/Controllers/Table/AddFieldControllerTest.php +++ b/tests/unit/Controllers/Table/AddFieldControllerTest.php @@ -261,7 +261,7 @@ class AddFieldControllerTest extends AbstractTestCase (new AddFieldController( $response, $transformations, - $this->createConfig(), + new Config(), $dbi, new ColumnsDefinition($dbi, $relation, $transformations), new DbTableExists($dbi), diff --git a/tests/unit/Controllers/Table/CreateControllerTest.php b/tests/unit/Controllers/Table/CreateControllerTest.php index bc13c7b0ec..4a3f547e24 100644 --- a/tests/unit/Controllers/Table/CreateControllerTest.php +++ b/tests/unit/Controllers/Table/CreateControllerTest.php @@ -276,7 +276,7 @@ class CreateControllerTest extends AbstractTestCase (new CreateController( $response, $transformations, - $this->createConfig(), + new Config(), $dbi, new ColumnsDefinition($dbi, $relation, $transformations), new UserPrivilegesFactory($dbi), diff --git a/tests/unit/Controllers/Table/Maintenance/AnalyzeControllerTest.php b/tests/unit/Controllers/Table/Maintenance/AnalyzeControllerTest.php index 8b110ce156..791aa80e67 100644 --- a/tests/unit/Controllers/Table/Maintenance/AnalyzeControllerTest.php +++ b/tests/unit/Controllers/Table/Maintenance/AnalyzeControllerTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Controllers\Table\Maintenance; +use PhpMyAdmin\Config; use PhpMyAdmin\Controllers\Table\Maintenance\AnalyzeController; use PhpMyAdmin\Dbal\DatabaseInterface; use PhpMyAdmin\Http\ServerRequest; @@ -25,7 +26,7 @@ class AnalyzeControllerTest extends AbstractTestCase $dbi = $this->createDatabaseInterface(); DatabaseInterface::$instance = $dbi; $response = new ResponseRenderer(); - $controller = new AnalyzeController($response, new Maintenance($dbi), $this->createConfig()); + $controller = new AnalyzeController($response, new Maintenance($dbi), new Config()); $controller($request); self::assertFalse($response->hasSuccessState()); self::assertSame(['message' => 'No table selected.'], $response->getJSONResult()); diff --git a/tests/unit/Controllers/Table/Maintenance/CheckControllerTest.php b/tests/unit/Controllers/Table/Maintenance/CheckControllerTest.php index 72ade86626..9d2a0e5414 100644 --- a/tests/unit/Controllers/Table/Maintenance/CheckControllerTest.php +++ b/tests/unit/Controllers/Table/Maintenance/CheckControllerTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Controllers\Table\Maintenance; +use PhpMyAdmin\Config; use PhpMyAdmin\Controllers\Table\Maintenance\CheckController; use PhpMyAdmin\Dbal\DatabaseInterface; use PhpMyAdmin\Http\ServerRequest; @@ -25,7 +26,7 @@ class CheckControllerTest extends AbstractTestCase $dbi = $this->createDatabaseInterface(); DatabaseInterface::$instance = $dbi; $response = new ResponseRenderer(); - $controller = new CheckController($response, new Maintenance($dbi), $this->createConfig()); + $controller = new CheckController($response, new Maintenance($dbi), new Config()); $controller($request); self::assertFalse($response->hasSuccessState()); self::assertSame(['message' => 'No table selected.'], $response->getJSONResult()); diff --git a/tests/unit/Controllers/Table/Maintenance/ChecksumControllerTest.php b/tests/unit/Controllers/Table/Maintenance/ChecksumControllerTest.php index 85a83aab1f..85f78964a8 100644 --- a/tests/unit/Controllers/Table/Maintenance/ChecksumControllerTest.php +++ b/tests/unit/Controllers/Table/Maintenance/ChecksumControllerTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Controllers\Table\Maintenance; +use PhpMyAdmin\Config; use PhpMyAdmin\Controllers\Table\Maintenance\ChecksumController; use PhpMyAdmin\Dbal\DatabaseInterface; use PhpMyAdmin\Http\ServerRequest; @@ -25,7 +26,7 @@ class ChecksumControllerTest extends AbstractTestCase $dbi = $this->createDatabaseInterface(); DatabaseInterface::$instance = $dbi; $response = new ResponseRenderer(); - $controller = new ChecksumController($response, new Maintenance($dbi), $this->createConfig()); + $controller = new ChecksumController($response, new Maintenance($dbi), new Config()); $controller($request); self::assertFalse($response->hasSuccessState()); self::assertSame(['message' => 'No table selected.'], $response->getJSONResult()); diff --git a/tests/unit/Controllers/Table/Maintenance/OptimizeControllerTest.php b/tests/unit/Controllers/Table/Maintenance/OptimizeControllerTest.php index 99ab3a58d9..cb79f99b7d 100644 --- a/tests/unit/Controllers/Table/Maintenance/OptimizeControllerTest.php +++ b/tests/unit/Controllers/Table/Maintenance/OptimizeControllerTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Controllers\Table\Maintenance; +use PhpMyAdmin\Config; use PhpMyAdmin\Controllers\Table\Maintenance\OptimizeController; use PhpMyAdmin\Dbal\DatabaseInterface; use PhpMyAdmin\Http\ServerRequest; @@ -25,7 +26,7 @@ class OptimizeControllerTest extends AbstractTestCase $dbi = $this->createDatabaseInterface(); DatabaseInterface::$instance = $dbi; $response = new ResponseRenderer(); - $controller = new OptimizeController($response, new Maintenance($dbi), $this->createConfig()); + $controller = new OptimizeController($response, new Maintenance($dbi), new Config()); $controller($request); self::assertFalse($response->hasSuccessState()); self::assertSame(['message' => 'No table selected.'], $response->getJSONResult()); diff --git a/tests/unit/Controllers/Table/Maintenance/RepairControllerTest.php b/tests/unit/Controllers/Table/Maintenance/RepairControllerTest.php index 1ac5af54a1..2c06e6ae57 100644 --- a/tests/unit/Controllers/Table/Maintenance/RepairControllerTest.php +++ b/tests/unit/Controllers/Table/Maintenance/RepairControllerTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Controllers\Table\Maintenance; +use PhpMyAdmin\Config; use PhpMyAdmin\Controllers\Table\Maintenance\RepairController; use PhpMyAdmin\Dbal\DatabaseInterface; use PhpMyAdmin\Http\ServerRequest; @@ -25,7 +26,7 @@ class RepairControllerTest extends AbstractTestCase $dbi = $this->createDatabaseInterface(); DatabaseInterface::$instance = $dbi; $response = new ResponseRenderer(); - $controller = new RepairController($response, new Maintenance($dbi), $this->createConfig()); + $controller = new RepairController($response, new Maintenance($dbi), new Config()); $controller($request); self::assertFalse($response->hasSuccessState()); self::assertSame(['message' => 'No table selected.'], $response->getJSONResult()); From 977cf11caf8f10646098c9c6fb6088944f5aec60 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 20 Jan 2026 23:24:17 +0000 Subject: [PATCH 03/11] Remove unnecessary Config::$instance assignments Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 9 --------- psalm-baseline.xml | 3 --- tests/unit/Bookmarks/BookmarkRepositoryTest.php | 3 +-- tests/unit/Config/Forms/Setup/FeaturesFormTest.php | 3 --- tests/unit/Config/ValidatorTest.php | 2 -- tests/unit/ConfigTest.php | 5 ----- tests/unit/Export/OptionsTest.php | 7 ------- 7 files changed, 1 insertion(+), 31 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5d77bcf8b2..50fbc96048 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -14292,15 +14292,6 @@ parameters: count: 5 path: tests/unit/ConfigStorage/RelationTest.php - - - message: ''' - #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: - Use dependency injection instead\.$# - ''' - identifier: staticMethod.deprecated - count: 1 - path: tests/unit/ConfigTest.php - - message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertArrayHasKey\(\) with ''Server'' and array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\} will always evaluate to false\.$#' identifier: staticMethod.impossibleType diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c353ba0f11..867abc8c6c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -9148,9 +9148,6 @@ - - - settings['Server']]]> settings['Server']]]> diff --git a/tests/unit/Bookmarks/BookmarkRepositoryTest.php b/tests/unit/Bookmarks/BookmarkRepositoryTest.php index 4ad6b8bdd9..e228abcf44 100644 --- a/tests/unit/Bookmarks/BookmarkRepositoryTest.php +++ b/tests/unit/Bookmarks/BookmarkRepositoryTest.php @@ -24,8 +24,7 @@ final class BookmarkRepositoryTest extends AbstractTestCase ]); (new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters); $dbi = $this->createDatabaseInterface(); - $config = Config::$instance = new Config(); - $bookmarkRepository = new BookmarkRepository($dbi, new Relation($dbi, $config)); + $bookmarkRepository = new BookmarkRepository($dbi, new Relation($dbi, new Config())); $bookmark = $bookmarkRepository->createBookmark('SELECT "phpmyadmin"', 'bookmark1', 'root', 'phpmyadmin'); self::assertNotFalse($bookmark); self::assertSame(0, $bookmark->getId()); diff --git a/tests/unit/Config/Forms/Setup/FeaturesFormTest.php b/tests/unit/Config/Forms/Setup/FeaturesFormTest.php index b3d44b6afa..e2ccb01ef6 100644 --- a/tests/unit/Config/Forms/Setup/FeaturesFormTest.php +++ b/tests/unit/Config/Forms/Setup/FeaturesFormTest.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Config\Forms\Setup; -use PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\Form; use PhpMyAdmin\Config\FormDisplay; @@ -22,8 +21,6 @@ final class FeaturesFormTest extends AbstractTestCase public function testRegisteredForms(): void { Form::resetGroupCounter(); - $config = new Config(); - Config::$instance = $config; $featuresForm = new FeaturesForm(new ConfigFile([]), 1); self::assertSame('Features', FeaturesForm::getName()); diff --git a/tests/unit/Config/ValidatorTest.php b/tests/unit/Config/ValidatorTest.php index fa6e65a2f9..77a5d86a61 100644 --- a/tests/unit/Config/ValidatorTest.php +++ b/tests/unit/Config/ValidatorTest.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Config; -use PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\Validator; use PhpMyAdmin\Tests\AbstractTestCase; @@ -15,7 +14,6 @@ final class ValidatorTest extends AbstractTestCase { public function testGetValidators(): void { - Config::$instance = new Config(); $validator = new Validator(new ConfigFile([])); $validators = $validator->getValidators(); $expected = [ diff --git a/tests/unit/ConfigTest.php b/tests/unit/ConfigTest.php index 3523206a82..0f8f22f32e 100644 --- a/tests/unit/ConfigTest.php +++ b/tests/unit/ConfigTest.php @@ -26,7 +26,6 @@ use function tempnam; use function unlink; use const CHANGELOG_FILE; -use const CONFIG_FILE; use const DIRECTORY_SEPARATOR; use const PHP_OS; @@ -52,10 +51,6 @@ class ConfigTest extends AbstractTestCase $this->object = $this->createConfig(); $_SESSION['git_location'] = '.git'; $_SESSION['is_git_revision'] = true; - Config::$instance = null; - $config = Config::getInstance(); - $config->loadFromFile(CONFIG_FILE); - $config->settings['ProxyUrl'] = ''; //for testing file permissions $this->permTestObj = new Config(); diff --git a/tests/unit/Export/OptionsTest.php b/tests/unit/Export/OptionsTest.php index 883842cc45..13cdc7f57c 100644 --- a/tests/unit/Export/OptionsTest.php +++ b/tests/unit/Export/OptionsTest.php @@ -54,13 +54,6 @@ class OptionsTest extends AbstractTestCase $this->export = new Options($relation, new TemplateModel($dbi), $userPreferencesHandler); } - protected function tearDown(): void - { - parent::tearDown(); - - Config::$instance = null; - } - public function testGetOptions(): void { $config = Config::getInstance(); From 4c2a4b4cd4c9e0ffbdaeaf67d243add8c0acae18 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 20 Jan 2026 23:40:10 +0000 Subject: [PATCH 04/11] Move $default to UserPreferencesHandler Signed-off-by: Kamil Tekiela --- src/Config.php | 4 ---- src/Config/UserPreferencesHandler.php | 6 +++++- tests/unit/ConfigTest.php | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Config.php b/src/Config.php index 1f7edac2c3..19e6ad5ca0 100644 --- a/src/Config.php +++ b/src/Config.php @@ -68,9 +68,6 @@ class Config { public static self|null $instance = null; - /** @var mixed[] default configuration settings */ - public array $default; - /** @var mixed[] configuration settings, without user preferences applied */ public array $baseSettings; @@ -102,7 +99,6 @@ class Config { $this->config = new Settings([]); $config = $this->config->asArray(); - $this->default = $config; $this->settings = $config; $this->baseSettings = $config; $this->selectedServer = (new Server())->asArray(); diff --git a/src/Config/UserPreferencesHandler.php b/src/Config/UserPreferencesHandler.php index c2c49eab57..092c2bd846 100644 --- a/src/Config/UserPreferencesHandler.php +++ b/src/Config/UserPreferencesHandler.php @@ -21,6 +21,9 @@ class UserPreferencesHandler /** @var ''|'db'|'session' */ public string $storageType = ''; + /** @var mixed[] default configuration settings */ + public array $defaultSettings; + public function __construct( private readonly Config $config, private readonly DatabaseInterface $dbi, @@ -28,6 +31,7 @@ class UserPreferencesHandler private readonly LanguageManager $languageManager, private readonly ThemeManager $themeManager, ) { + $this->defaultSettings = (new Settings([]))->asArray(); } /** @@ -165,7 +169,7 @@ class UserPreferencesHandler // use permanent user preferences if possible if ($this->storageType !== '') { if ($defaultValue === null) { - $defaultValue = Core::arrayRead($cfgPath, $this->config->default); + $defaultValue = Core::arrayRead($cfgPath, $this->defaultSettings); } $result = $this->userPreferences->persistOption($cfgPath, $newCfgValue, $defaultValue); diff --git a/tests/unit/ConfigTest.php b/tests/unit/ConfigTest.php index 0f8f22f32e..c74d2c2a27 100644 --- a/tests/unit/ConfigTest.php +++ b/tests/unit/ConfigTest.php @@ -162,7 +162,6 @@ class ConfigTest extends AbstractTestCase $config = $settings->asArray(); self::assertIsArray($config['Servers']); self::assertEquals($settings, $object->getSettings()); - self::assertSame($config, $object->default); self::assertSame($config, $object->settings); self::assertSame($config, $object->baseSettings); } From 24fba41d3deeace2d1f3893e828829458fb16b60 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 21 Jan 2026 01:13:05 +0000 Subject: [PATCH 05/11] Remove array_replace_recursive This was only necessary in the past to ensure we only load the existing settings. Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 6 ------ psalm-baseline.xml | 3 --- src/Config.php | 3 +-- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 50fbc96048..efdc696e7b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -312,12 +312,6 @@ parameters: count: 1 path: src/Config.php - - - message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\.$#' - identifier: assign.propertyType - count: 1 - path: src/Config.php - - message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept non\-empty\-array\\.$#' identifier: assign.propertyType diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 867abc8c6c..5cf72a4be7 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -118,9 +118,6 @@ settings]]> settings]]> - - settings, $this->config->asArray())]]> - getCookieName($cookieName)]]]> diff --git a/src/Config.php b/src/Config.php index 19e6ad5ca0..0565896cfa 100644 --- a/src/Config.php +++ b/src/Config.php @@ -13,7 +13,6 @@ use Throwable; use function __; use function array_key_last; -use function array_replace_recursive; use function array_slice; use function count; use function defined; @@ -204,7 +203,7 @@ class Config } $this->config = new Settings($cfg); - $this->settings = array_replace_recursive($this->settings, $this->config->asArray()); + $this->settings = $this->config->asArray(); } /** From 90a5c4ca7837502069f247f14cb1607353e4d6ba Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 21 Jan 2026 02:06:11 +0000 Subject: [PATCH 06/11] Expand Config::set() Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 14 +------- psalm-baseline.xml | 13 ++++---- src/Config.php | 33 +++++++++++++++++-- src/Config/UserPreferencesHandler.php | 4 +-- src/Theme/ThemeManager.php | 3 -- .../Config/UserPreferencesHandlerTest.php | 4 +-- 6 files changed, 41 insertions(+), 30 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index efdc696e7b..241ab67c06 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -313,7 +313,7 @@ parameters: path: src/Config.php - - message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept non\-empty\-array\\.$#' + message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\\.$#' identifier: assign.propertyType count: 1 path: src/Config.php @@ -945,12 +945,6 @@ parameters: count: 5 path: src/Config/UserPreferencesHandler.php - - - message: '#^Cannot access offset ''userprefs_mtime'' on mixed\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 2 - path: src/Config/UserPreferencesHandler.php - - message: '#^Cannot access offset ''userprefs_type'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -1005,12 +999,6 @@ parameters: count: 1 path: src/Config/UserPreferencesHandler.php - - - message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\\.$#' - identifier: assign.propertyType - count: 1 - path: src/Config/UserPreferencesHandler.php - - message: '#^Property PhpMyAdmin\\Config\\UserPreferencesHandler\:\:\$storageType \(''''\|''db''\|''session''\) does not accept mixed\.$#' identifier: assign.propertyType diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5cf72a4be7..f85d278bac 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -118,12 +118,15 @@ settings]]> settings]]> + + + + + settings]]> + getCookieName($cookieName)]]]> - - settings]]> - @@ -417,7 +420,6 @@ - @@ -425,10 +427,8 @@ - - @@ -439,7 +439,6 @@ - config->settings]]> config->settings, $configData)]]> diff --git a/src/Config.php b/src/Config.php index 0565896cfa..b64253913e 100644 --- a/src/Config.php +++ b/src/Config.php @@ -13,6 +13,7 @@ use Throwable; use function __; use function array_key_last; +use function array_shift; use function array_slice; use function count; use function defined; @@ -283,17 +284,45 @@ class Config * * @param string $setting configuration option * @param mixed $value new value for configuration option + * + * @throws ConfigException */ public function set(string $setting, mixed $value): void { - if (isset($this->settings[$setting]) && $this->settings[$setting] === $value) { + $parts = explode('/', $setting); + if (! $this->setValueRecursive($this->settings, $parts, $value)) { return; } - $this->settings[$setting] = $value; $this->config = new Settings($this->settings); } + /** + * @param mixed[] $array + * @param array-key[] $parts + * + * @throws ConfigException + */ + private function setValueRecursive(array &$array, array $parts, mixed $value): bool + { + $part = array_shift($parts); + if ($parts === []) { + if ($array[$part] === $value) { + return false; + } + + $array[$part] = $value; + + return true; + } + + if (! is_array($array[$part])) { + throw new ConfigException('Failed to set configuration value.'); + } + + return $this->setValueRecursive($array[$part], $parts, $value); + } + /** * returns source for current config * diff --git a/src/Config/UserPreferencesHandler.php b/src/Config/UserPreferencesHandler.php index 092c2bd846..e524e6473f 100644 --- a/src/Config/UserPreferencesHandler.php +++ b/src/Config/UserPreferencesHandler.php @@ -49,7 +49,6 @@ class UserPreferencesHandler ) { $prefs = $this->userPreferences->load(); $_SESSION['cache'][$cacheKey]['userprefs'] = $this->userPreferences->apply($prefs['config_data']); - $_SESSION['cache'][$cacheKey]['userprefs_mtime'] = $prefs['mtime']; $_SESSION['cache'][$cacheKey]['userprefs_type'] = $prefs['type']; $_SESSION['cache'][$cacheKey]['config_mtime'] = $this->config->sourceMtime; } @@ -62,7 +61,6 @@ class UserPreferencesHandler $configData = $_SESSION['cache'][$cacheKey]['userprefs']; // type is 'db' or 'session' $this->storageType = $_SESSION['cache'][$cacheKey]['userprefs_type']; - $this->config->set('user_preferences_mtime', $_SESSION['cache'][$cacheKey]['userprefs_mtime']); if (isset($configData['Server']) && is_array($configData['Server'])) { $serverConfig = array_replace_recursive($this->config->selectedServer, $configData['Server']); @@ -184,7 +182,7 @@ class UserPreferencesHandler $this->config->setCookie($cookieName, (string) $newCfgValue, $defaultValue); } - Core::arrayWrite($cfgPath, $this->config->settings, $newCfgValue); + $this->config->set($cfgPath, $newCfgValue); return $result; } diff --git a/src/Theme/ThemeManager.php b/src/Theme/ThemeManager.php index ddcfcfbac1..552cce34c5 100644 --- a/src/Theme/ThemeManager.php +++ b/src/Theme/ThemeManager.php @@ -176,9 +176,6 @@ class ThemeManager $this->theme->getColorMode(), $this->theme->getColorModes()[0], ); - // force a change of a dummy session variable to avoid problems - // with the caching of phpmyadmin.css.php - $config->set('theme-update', $this->theme->id); } public function loadThemes(): void diff --git a/tests/unit/Config/UserPreferencesHandlerTest.php b/tests/unit/Config/UserPreferencesHandlerTest.php index 0bb4bc75ac..a8fe693999 100644 --- a/tests/unit/Config/UserPreferencesHandlerTest.php +++ b/tests/unit/Config/UserPreferencesHandlerTest.php @@ -29,8 +29,8 @@ final class UserPreferencesHandlerTest extends AbstractTestCase new LanguageManager($config), new ThemeManager(), ); - $userPreferencesHandler->setUserValue(null, 'lang', 'cs', 'en'); - $userPreferencesHandler->setUserValue('TEST_COOKIE_USER_VAL', '', 'cfg_val_1'); + $userPreferencesHandler->setUserValue(null, 'Lang', 'cs', 'en'); + $userPreferencesHandler->setUserValue('TEST_COOKIE_USER_VAL', 'Servers/1/hide_db', 'cfg_val_1'); self::assertSame('cfg_val_1', $userPreferencesHandler->getUserValue('TEST_COOKIE_USER_VAL', 'fail')); $userPreferencesHandler->setUserValue(null, 'NavigationWidth', 300); self::assertSame(300, $config->settings['NavigationWidth']); From b6a9e497b5bc02759860e613ea15d3321c2274f5 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 21 Jan 2026 02:32:04 +0000 Subject: [PATCH 07/11] Don't change config value Signed-off-by: Kamil Tekiela --- src/Controllers/UserPasswordController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Controllers/UserPasswordController.php b/src/Controllers/UserPasswordController.php index 6c93ff708e..9e261d3b5c 100644 --- a/src/Controllers/UserPasswordController.php +++ b/src/Controllers/UserPasswordController.php @@ -39,11 +39,12 @@ final readonly class UserPasswordController implements InvocableController * Displays an error message and exits if the user isn't allowed to use this * script */ + $hasAccessPrivilege = true; if (! $this->config->settings['ShowChgPassword']) { - $this->config->settings['ShowChgPassword'] = $this->dbi->selectDb('mysql'); + $hasAccessPrivilege = $this->dbi->selectDb('mysql'); } - if ($this->config->selectedServer['auth_type'] === 'config' || ! $this->config->settings['ShowChgPassword']) { + if ($this->config->selectedServer['auth_type'] === 'config' || ! $hasAccessPrivilege) { $this->response->addHTML(Message::error( __('You don\'t have sufficient privileges to be here right now!'), )->getDisplay()); From 06b65b1cd73e00f9b4e20ed981cdbc87dfc44577 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 21 Jan 2026 02:51:25 +0000 Subject: [PATCH 08/11] Make settings symmetrical Signed-off-by: Kamil Tekiela --- src/Config.php | 1 + src/Config/Settings.php | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/Config.php b/src/Config.php index b64253913e..6a9a3185b9 100644 --- a/src/Config.php +++ b/src/Config.php @@ -295,6 +295,7 @@ class Config } $this->config = new Settings($this->settings); + $this->settings = $this->config->asArray(); } /** diff --git a/src/Config/Settings.php b/src/Config/Settings.php index 43410c0417..4cdabfc95c 100644 --- a/src/Config/Settings.php +++ b/src/Config/Settings.php @@ -3920,10 +3920,10 @@ final class Settings } return match ($settings['NavigationTreeDefaultTabTable']) { - 'sql', 'tbl_sql.php' => '/table/sql', - 'search', 'tbl_select.php' => '/table/search', - 'insert', 'tbl_change.php' => '/table/change', - 'browse', 'sql.php' => '/sql', + 'sql', 'tbl_sql.php', '/table/sql' => '/table/sql', + 'search', 'tbl_select.php', '/table/search' => '/table/search', + 'insert', 'tbl_change.php', '/table/change' => '/table/change', + 'browse', 'sql.php', '/sql' => '/sql', default => '/table/structure', }; } @@ -3940,11 +3940,11 @@ final class Settings } return match ($settings['NavigationTreeDefaultTabTable2']) { - 'structure', 'tbl_structure.php' => '/table/structure', - 'sql', 'tbl_sql.php' => '/table/sql', - 'search', 'tbl_select.php' => '/table/search', - 'insert', 'tbl_change.php' => '/table/change', - 'browse', 'sql.php' => '/sql', + 'structure', 'tbl_structure.php', '/table/structure' => '/table/structure', + 'sql', 'tbl_sql.php', '/table/sql' => '/table/sql', + 'search', 'tbl_select.php', '/table/search' => '/table/search', + 'insert', 'tbl_change.php', '/table/change' => '/table/change', + 'browse', 'sql.php', '/sql' => '/sql', default => '', }; } @@ -4520,10 +4520,10 @@ final class Settings } return match ($settings['DefaultTabServer']) { - 'databases', 'server_databases.php' => '/server/databases', - 'status', 'server_status.php' => '/server/status', - 'variables', 'server_variables.php' => '/server/variables', - 'privileges', 'server_privileges.php' => '/server/privileges', + 'databases', 'server_databases.php', '/server/databases' => '/server/databases', + 'status', 'server_status.php', '/server/status' => '/server/status', + 'variables', 'server_variables.php', '/server/variables' => '/server/variables', + 'privileges', 'server_privileges.php', '/server/privileges' => '/server/privileges', default => '/', }; } @@ -4540,9 +4540,9 @@ final class Settings } return match ($settings['DefaultTabDatabase']) { - 'sql', 'db_sql.php' => '/database/sql', - 'search', 'db_search.php' => '/database/search', - 'operations', 'db_operations.php' => '/database/operations', + 'sql', 'db_sql.php', '/database/sql' => '/database/sql', + 'search', 'db_search.php', '/database/search' => '/database/search', + 'operations', 'db_operations.php', '/database/operations' => '/database/operations', default => '/database/structure', }; } @@ -4559,10 +4559,10 @@ final class Settings } return match ($settings['DefaultTabTable']) { - 'structure', 'tbl_structure.php' => '/table/structure', - 'sql', 'tbl_sql.php' => '/table/sql', - 'search', 'tbl_select.php' => '/table/search', - 'insert', 'tbl_change.php' => '/table/change', + 'structure', 'tbl_structure.php', '/table/structure' => '/table/structure', + 'sql', 'tbl_sql.php', '/table/sql' => '/table/sql', + 'search', 'tbl_select.php', '/table/search' => '/table/search', + 'insert', 'tbl_change.php', '/table/change' => '/table/change', default => '/sql', }; } From 5db00e0b397a59788db73094500b0b519751adeb Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 21 Jan 2026 16:21:46 +0000 Subject: [PATCH 09/11] Inline boolean variable Signed-off-by: Kamil Tekiela --- src/Controllers/UserPasswordController.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Controllers/UserPasswordController.php b/src/Controllers/UserPasswordController.php index 9e261d3b5c..8fb973da06 100644 --- a/src/Controllers/UserPasswordController.php +++ b/src/Controllers/UserPasswordController.php @@ -39,10 +39,7 @@ final readonly class UserPasswordController implements InvocableController * Displays an error message and exits if the user isn't allowed to use this * script */ - $hasAccessPrivilege = true; - if (! $this->config->settings['ShowChgPassword']) { - $hasAccessPrivilege = $this->dbi->selectDb('mysql'); - } + $hasAccessPrivilege = $this->config->config->ShowChgPassword || $this->dbi->selectDb('mysql'); if ($this->config->selectedServer['auth_type'] === 'config' || ! $hasAccessPrivilege) { $this->response->addHTML(Message::error( From d412a0e7d7df4d8a3f607eda700273123731e437 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 21 Jan 2026 18:11:36 +0000 Subject: [PATCH 10/11] Fix failing test Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 16 ++-------- psalm-baseline.xml | 42 ++++++++++----------------- src/Utils/SessionCache.php | 5 +--- tests/unit/UtilTest.php | 10 +++---- tests/unit/Utils/SessionCacheTest.php | 26 ++++++++--------- 5 files changed, 37 insertions(+), 62 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 241ab67c06..a4019da3bb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -16885,7 +16885,7 @@ parameters: path: tests/unit/UtilTest.php - - message: '#^Cannot access offset ''server_2'' on mixed\.$#' + message: '#^Cannot access offset ''server_2_'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible count: 4 path: tests/unit/UtilTest.php @@ -16896,12 +16896,6 @@ parameters: count: 2 path: tests/unit/UtilTest.php - - - message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#' - identifier: assign.propertyType - count: 1 - path: tests/unit/UtilTest.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: @@ -16963,7 +16957,7 @@ parameters: path: tests/unit/Utils/SessionCacheTest.php - - message: '#^Cannot access offset ''server_2'' on mixed\.$#' + message: '#^Cannot access offset ''server_2_'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible count: 4 path: tests/unit/Utils/SessionCacheTest.php @@ -16992,12 +16986,6 @@ parameters: count: 2 path: tests/unit/Utils/SessionCacheTest.php - - - message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#' - identifier: assign.propertyType - count: 5 - path: tests/unit/Utils/SessionCacheTest.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: diff --git a/psalm-baseline.xml b/psalm-baseline.xml index f85d278bac..e3a8bac908 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -10826,20 +10826,17 @@ - - selectedServer]]> - - - + + - - - - - - + + + + + + @@ -10912,24 +10909,17 @@ - - selectedServer]]> - selectedServer]]> - selectedServer]]> - selectedServer]]> - selectedServer]]> - - - + + - - - - - - + + + + + + diff --git a/src/Utils/SessionCache.php b/src/Utils/SessionCache.php index facbba81c1..712d7d6f7f 100644 --- a/src/Utils/SessionCache.php +++ b/src/Utils/SessionCache.php @@ -14,11 +14,8 @@ final class SessionCache $key = 'server_' . Current::$server; $config = Config::getInstance(); - if (isset($config->selectedServer['user'])) { - return $key . '_' . $config->selectedServer['user']; - } - return $key; + return $key . '_' . $config->selectedServer['user']; } public static function has(string $name): bool diff --git a/tests/unit/UtilTest.php b/tests/unit/UtilTest.php index f24fccf29b..d307a63e12 100644 --- a/tests/unit/UtilTest.php +++ b/tests/unit/UtilTest.php @@ -104,17 +104,17 @@ class UtilTest extends AbstractTestCase public function testClearUserCache(): void { - Config::getInstance()->selectedServer['user'] = null; + Config::getInstance()->selectedServer['user'] = ''; Current::$server = 2; SessionCache::set('is_superuser', 'yes'); - self::assertSame('yes', $_SESSION['cache']['server_2']['is_superuser']); + self::assertSame('yes', $_SESSION['cache']['server_2_']['is_superuser']); SessionCache::set('mysql_cur_user', 'mysql'); - self::assertSame('mysql', $_SESSION['cache']['server_2']['mysql_cur_user']); + self::assertSame('mysql', $_SESSION['cache']['server_2_']['mysql_cur_user']); Util::clearUserCache(); - self::assertArrayNotHasKey('is_superuser', $_SESSION['cache']['server_2']); - self::assertArrayNotHasKey('mysql_cur_user', $_SESSION['cache']['server_2']); + self::assertArrayNotHasKey('is_superuser', $_SESSION['cache']['server_2_']); + self::assertArrayNotHasKey('mysql_cur_user', $_SESSION['cache']['server_2_']); } /** diff --git a/tests/unit/Utils/SessionCacheTest.php b/tests/unit/Utils/SessionCacheTest.php index 07b762df5e..ce8ba61109 100644 --- a/tests/unit/Utils/SessionCacheTest.php +++ b/tests/unit/Utils/SessionCacheTest.php @@ -16,7 +16,7 @@ class SessionCacheTest extends TestCase public function testGet(): void { $_SESSION = []; - Config::getInstance()->selectedServer['user'] = null; + Config::getInstance()->selectedServer['user'] = ''; SessionCache::set('test_data', 5); SessionCache::set('test_data_2', 5); @@ -29,35 +29,35 @@ class SessionCacheTest extends TestCase public function testRemove(): void { $_SESSION = []; - Config::getInstance()->selectedServer['user'] = null; + Config::getInstance()->selectedServer['user'] = ''; Current::$server = 2; SessionCache::set('test_data', 25); SessionCache::set('test_data_2', 25); SessionCache::remove('test_data'); - self::assertArrayNotHasKey('test_data', $_SESSION['cache']['server_2']); + self::assertArrayNotHasKey('test_data', $_SESSION['cache']['server_2_']); SessionCache::remove('test_data_2'); - self::assertArrayNotHasKey('test_data_2', $_SESSION['cache']['server_2']); + self::assertArrayNotHasKey('test_data_2', $_SESSION['cache']['server_2_']); } public function testSet(): void { $_SESSION = []; - Config::getInstance()->selectedServer['user'] = null; + Config::getInstance()->selectedServer['user'] = ''; Current::$server = 2; SessionCache::set('test_data', 25); SessionCache::set('test_data', 5); - self::assertSame(5, $_SESSION['cache']['server_2']['test_data']); + self::assertSame(5, $_SESSION['cache']['server_2_']['test_data']); SessionCache::set('test_data_3', 3); - self::assertSame(3, $_SESSION['cache']['server_2']['test_data_3']); + self::assertSame(3, $_SESSION['cache']['server_2_']['test_data_3']); } public function testHas(): void { $_SESSION = []; - Config::getInstance()->selectedServer['user'] = null; + Config::getInstance()->selectedServer['user'] = ''; SessionCache::set('test_data', 5); SessionCache::set('test_data_2', 5); @@ -74,16 +74,16 @@ class SessionCacheTest extends TestCase public function testKeyWithoutUser(): void { $_SESSION = []; - Config::getInstance()->selectedServer['user'] = null; + Config::getInstance()->selectedServer['user'] = ''; Current::$server = 123; SessionCache::set('test_data', 5); self::assertArrayHasKey('cache', $_SESSION); self::assertIsArray($_SESSION['cache']); - self::assertArrayHasKey('server_123', $_SESSION['cache']); - self::assertIsArray($_SESSION['cache']['server_123']); - self::assertArrayHasKey('test_data', $_SESSION['cache']['server_123']); - self::assertSame(5, $_SESSION['cache']['server_123']['test_data']); + self::assertArrayHasKey('server_123_', $_SESSION['cache']); + self::assertIsArray($_SESSION['cache']['server_123_']); + self::assertArrayHasKey('test_data', $_SESSION['cache']['server_123_']); + self::assertSame(5, $_SESSION['cache']['server_123_']['test_data']); } public function testKeyWithUser(): void From 95c707d016e036c33d3c9091a3316653a34006c7 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Thu, 22 Jan 2026 16:01:34 +0000 Subject: [PATCH 11/11] Fix failing test Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 6 ------ tests/unit/TwoFactorTest.php | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a4019da3bb..3bd855e4fd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -16815,12 +16815,6 @@ parameters: count: 1 path: tests/unit/TwoFactorTest.php - - - message: '#^Missing call to parent\:\:tearDown\(\) method\.$#' - identifier: phpunit.callParent - count: 1 - path: tests/unit/TwoFactorTest.php - - message: '#^Parameter \#1 \$secret of method PragmaRX\\Google2FA\\Google2FA\:\:oathTotp\(\) expects string, mixed given\.$#' identifier: argument.type diff --git a/tests/unit/TwoFactorTest.php b/tests/unit/TwoFactorTest.php index 39695696c8..17cc566af7 100644 --- a/tests/unit/TwoFactorTest.php +++ b/tests/unit/TwoFactorTest.php @@ -61,6 +61,8 @@ class TwoFactorTest extends AbstractTestCase protected function tearDown(): void { $this->dummyDbi->assertAllSelectsConsumed(); + + parent::tearDown(); } private function initStorageConfigAndData(): void