diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 57c991754b..8b0025c873 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -15475,11 +15475,6 @@ parameters:
count: 1
path: tests/unit/Config/SettingsTest.php
- -
- message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Config\\\\\\\\Settings\\\\\\\\Debug' and PhpMyAdmin\\\\Config\\\\Settings\\\\Debug will always evaluate to true\\.$#"
- count: 1
- path: tests/unit/Config/SettingsTest.php
-
-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with 'PhpMyAdmin\\\\\\\\Config\\\\\\\\Settings\\\\\\\\Export' and PhpMyAdmin\\\\Config\\\\Settings\\\\Export will always evaluate to true\\.$#"
count: 1
@@ -16725,16 +16720,6 @@ parameters:
count: 2
path: tests/unit/Tracking/TrackingTest.php
- -
- message: "#^Cannot access offset 'sql' on mixed\\.$#"
- count: 1
- path: tests/unit/TransformationsTest.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\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\.$#"
- count: 1
- path: tests/unit/TransformationsTest.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\\{ServerDefault\\: 1, ActionLinksMode\\: 'icons'\\}\\.$#"
count: 1
@@ -16755,11 +16740,6 @@ parameters:
count: 2
path: tests/unit/TwoFactorTest.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\\{PmaAbsoluteUri\\: string, AuthLog\\: string, AuthLogSuccess\\: bool, PmaNoRelation_DisableWarning\\: bool, SuhosinDisableWarning\\: bool, LoginCookieValidityDisableWarning\\: bool, ReservedWordDisableWarning\\: bool, TranslationWarningThreshold\\: int, \\.\\.\\.\\}\\.$#"
- count: 1
- path: tests/unit/TwoFactorTest.php
-
-
message: "#^Class PhpMyAdmin\\\\Tests\\\\TypesByDatabaseVersionTest has an uninitialized property \\$object\\. Give it default value or assign it in the constructor\\.$#"
count: 1
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 8ab41af3e5..a6a668696f 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -12245,6 +12245,7 @@
+
@@ -13231,6 +13232,10 @@
+
+ config->debug->sql]]>
+ config->debug->sql]]>
+
@@ -13440,6 +13445,10 @@
+
+ config->debug->sql]]>
+ config->debug->sql]]>
+
@@ -14409,7 +14418,6 @@
settings]]>
settings]]>
settings]]>
- settings]]>
@@ -14562,11 +14570,6 @@
-
-
-
-
-
result, 1, 0)]]>
@@ -14699,7 +14702,6 @@
- settings]]>
1, 'ActionLinksMode' => 'icons']]]>
@@ -14737,10 +14739,14 @@
-
- settings]]>
- settings]]>
-
+
+ config->debug->simple2fa]]>
+ config->debug->simple2fa]]>
+ config->debug->simple2fa]]>
+ config->debug->simple2fa]]>
+ config->debug->simple2fa]]>
+ config->debug->simple2fa]]>
+
config['settings']['secret']]]>
config['settings']['secret']]]>
diff --git a/src/Config/Settings.php b/src/Config/Settings.php
index 8d7bf03b9c..cacca8779b 100644
--- a/src/Config/Settings.php
+++ b/src/Config/Settings.php
@@ -2507,7 +2507,7 @@ final class Settings
*
* @link https://docs.phpmyadmin.net/en/latest/config.html#cfg_DBG
*/
- public Debug $DBG;
+ public Debug $debug;
/**
* Sets the working environment
@@ -2808,7 +2808,7 @@ final class Settings
$this->SendErrorReports = $this->setSendErrorReports($settings);
$this->ConsoleEnterExecutes = $this->setConsoleEnterExecutes($settings);
$this->zeroConf = $this->setZeroConf($settings);
- $this->DBG = $this->setDBG($settings);
+ $this->debug = $this->setDebug($settings);
$this->environment = $this->setEnvironment($settings);
$this->DefaultFunctions = $this->setDefaultFunctions($settings);
$this->maxRowPlotLimit = $this->setMaxRowPlotLimit($settings);
@@ -3006,7 +3006,7 @@ final class Settings
'SendErrorReports' => $this->SendErrorReports,
'ConsoleEnterExecutes' => $this->ConsoleEnterExecutes,
'ZeroConf' => $this->zeroConf,
- 'DBG' => $this->DBG->asArray(),
+ 'DBG' => $this->debug->asArray(),
'environment' => $this->environment,
'DefaultFunctions' => $this->DefaultFunctions,
'maxRowPlotLimit' => $this->maxRowPlotLimit,
@@ -5389,7 +5389,7 @@ final class Settings
}
/** @param array $settings */
- private function setDBG(array $settings): Debug
+ private function setDebug(array $settings): Debug
{
if (isset($settings['DBG']) && is_array($settings['DBG'])) {
return new Debug($settings['DBG']);
diff --git a/src/Config/Validator.php b/src/Config/Validator.php
index cd0fdf7a68..d3dca2780f 100644
--- a/src/Config/Validator.php
+++ b/src/Config/Validator.php
@@ -220,7 +220,8 @@ class Validator
string $pass,
string $errorKey = 'Server',
): bool|array {
- if (Config::getInstance()->settings['DBG']['demo']) {
+ $config = Config::getInstance();
+ if ($config->config->debug->demo) {
// Connection test disabled on the demo server!
return true;
}
diff --git a/src/Console.php b/src/Console.php
index 8f735f5f33..e5197c509f 100644
--- a/src/Console.php
+++ b/src/Console.php
@@ -111,13 +111,12 @@ class Console
$bookmarkFeature = $this->relation->getRelationParameters()->bookmarkFeature;
$sqlHistory = $this->relation->getHistory($this->config->selectedServer['user']);
$bookmarkContent = $this->getBookmarkContent();
- $debug = isset($this->config->settings['DBG']) && $this->config->settings['DBG']['sql'];
return $this->template->render('console/display', [
'has_bookmark_feature' => $bookmarkFeature !== null,
'sql_history' => $sqlHistory,
'bookmark_content' => $bookmarkContent,
- 'debug' => $debug,
+ 'debug' => $this->config->config->debug->sql,
]);
}
}
diff --git a/src/Controllers/HomeController.php b/src/Controllers/HomeController.php
index 1f6e0608f2..e8b30187c9 100644
--- a/src/Controllers/HomeController.php
+++ b/src/Controllers/HomeController.php
@@ -229,7 +229,7 @@ class HomeController extends AbstractController
'server' => Current::$server,
'sync_favorite_tables' => $syncFavoriteTables,
'has_server' => $hasServer,
- 'is_demo' => $config->settings['DBG']['demo'],
+ 'is_demo' => $config->config->debug->demo,
'has_server_selection' => $hasServerSelection ?? false,
'server_selection' => $serverSelection ?? '',
'has_change_password_link' => ($config->selectedServer['auth_type'] ?? '') !== 'config'
diff --git a/src/Controllers/Setup/MainController.php b/src/Controllers/Setup/MainController.php
index 4e4acd31f0..6b74caacef 100644
--- a/src/Controllers/Setup/MainController.php
+++ b/src/Controllers/Setup/MainController.php
@@ -33,7 +33,7 @@ final class MainController
public function __invoke(ServerRequest $request): Response
{
$config = Config::getInstance();
- if (@file_exists(CONFIG_FILE) && ! $config->settings['DBG']['demo']) {
+ if (@file_exists(CONFIG_FILE) && ! $config->config->debug->demo) {
$response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_NOT_FOUND);
return $response->write($this->template->render('error/generic', [
diff --git a/src/DatabaseInterface.php b/src/DatabaseInterface.php
index ef580b634e..8fea9bec39 100644
--- a/src/DatabaseInterface.php
+++ b/src/DatabaseInterface.php
@@ -209,7 +209,6 @@ class DatabaseInterface implements DbalInterface
int $options = self::QUERY_BUFFERED,
bool $cacheAffectedRows = true,
): ResultInterface|false {
- $debug = isset($this->config->settings['DBG']) && $this->config->settings['DBG']['sql'];
if (! isset($this->connections[$connectionType->value])) {
return false;
}
@@ -226,7 +225,7 @@ class DatabaseInterface implements DbalInterface
$GLOBALS['cached_affected_rows'] = $this->affectedRows($connectionType, false);
}
- if ($debug) {
+ if ($this->config->config->debug->sql) {
$errorMessage = $this->getError($connectionType);
Utilities::debugLogQueryIntoSession(
$query,
@@ -234,7 +233,7 @@ class DatabaseInterface implements DbalInterface
$result,
$this->lastQueryExecutionTime,
);
- if ($this->config->settings['DBG']['sqllog']) {
+ if ($this->config->config->debug->sqllog) {
openlog('phpMyAdmin', LOG_NDELAY | LOG_PID, LOG_USER);
syslog(
diff --git a/src/Footer.php b/src/Footer.php
index b18aa8a4c1..46f3a240a4 100644
--- a/src/Footer.php
+++ b/src/Footer.php
@@ -101,9 +101,7 @@ class Footer
public function getDebugMessage(): string
{
$retval = '\'false\'';
- if (
- $this->config->settings['DBG']['sql'] && empty($_REQUEST['no_debug']) && ! empty($_SESSION['debug'])
- ) {
+ if ($this->config->config->debug->sql && empty($_REQUEST['no_debug']) && ! empty($_SESSION['debug'])) {
// Remove recursions and iterators from $_SESSION['debug']
self::removeRecursion($_SESSION['debug']);
@@ -241,7 +239,7 @@ class Footer
$errorMessages = $this->getErrorMessages();
$scripts = $this->scripts->getDisplay();
- if ($this->config->settings['DBG']['demo']) {
+ if ($this->config->config->debug->demo) {
$gitRevisionInfo = $this->getGitRevisionInfo();
}
@@ -254,7 +252,7 @@ class Footer
'self_url' => $url ?? null,
'error_messages' => $errorMessages ?? '',
'scripts' => $scripts ?? '',
- 'is_demo' => $this->config->settings['DBG']['demo'],
+ 'is_demo' => $this->config->config->debug->demo,
'git_revision_info' => $gitRevisionInfo ?? [],
'footer' => $footer ?? '',
]);
diff --git a/src/Plugins/Auth/AuthenticationCookie.php b/src/Plugins/Auth/AuthenticationCookie.php
index 1f95343763..5756237b6d 100644
--- a/src/Plugins/Auth/AuthenticationCookie.php
+++ b/src/Plugins/Auth/AuthenticationCookie.php
@@ -161,7 +161,7 @@ class AuthenticationCookie extends AuthenticationPlugin
$response->addHTML($this->template->render('login/form', [
'login_header' => $loginHeader,
- 'is_demo' => $config->settings['DBG']['demo'],
+ 'is_demo' => $config->config->debug->demo,
'error_messages' => $errorMessages,
'available_languages' => $availableLanguages,
'is_session_expired' => $sessionExpired,
diff --git a/src/TwoFactor.php b/src/TwoFactor.php
index b167e04e4c..2b77f92392 100644
--- a/src/TwoFactor.php
+++ b/src/TwoFactor.php
@@ -118,7 +118,8 @@ class TwoFactor
public function getAvailableBackends(): array
{
$result = [];
- if (Config::getInstance()->settings['DBG']['simple2fa']) {
+ $config = Config::getInstance();
+ if ($config->config->debug->simple2fa) {
$result[] = 'simple';
}
diff --git a/tests/unit/Config/SettingsTest.php b/tests/unit/Config/SettingsTest.php
index 530b889ab4..654de351b7 100644
--- a/tests/unit/Config/SettingsTest.php
+++ b/tests/unit/Config/SettingsTest.php
@@ -226,7 +226,6 @@ class SettingsTest extends TestCase
'DisableMultiTableMaintenance' => false,
'SendErrorReports' => 'ask',
'ConsoleEnterExecutes' => false,
- 'DBG' => null,
'environment' => 'production',
'DefaultFunctions' => [
'FUNC_CHAR' => '',
@@ -268,11 +267,6 @@ class SettingsTest extends TestCase
continue;
}
- if ($key === 'DBG') {
- self::assertInstanceOf(Debug::class, $settings->DBG);
- continue;
- }
-
if ($key === 'Export') {
self::assertInstanceOf(Export::class, $settings->Export);
continue;
@@ -468,7 +462,6 @@ class SettingsTest extends TestCase
['DisableMultiTableMaintenance', null, false],
['SendErrorReports', null, 'ask'],
['ConsoleEnterExecutes', null, false],
- ['DBG', null, null],
['environment', null, 'production'],
['DefaultFunctions', null, ['FUNC_CHAR' => '', 'FUNC_DATE' => '', 'FUNC_NUMBER' => '', 'FUNC_SPATIAL' => 'GeomFromText', 'FUNC_UUID' => 'UUID', 'first_timestamp' => 'NOW']],
['maxRowPlotLimit', null, 500],
@@ -634,7 +627,6 @@ class SettingsTest extends TestCase
['DisableMultiTableMaintenance', true, true],
['SendErrorReports', 'never', 'never'],
['ConsoleEnterExecutes', true, true],
- ['DBG', [], null],
['environment', 'development', 'development'],
['DefaultFunctions', ['key' => 'value', 'key2' => 'value2'], ['key' => 'value', 'key2' => 'value2']],
['maxRowPlotLimit', 1, 1],
@@ -963,7 +955,6 @@ class SettingsTest extends TestCase
['TrustedProxies', 'invalid', []],
['LinkLengthLimit', 0, 1000],
['SendErrorReports', 'invalid', 'ask'],
- ['DBG', 'invalid', null],
['environment', 'invalid', 'production'],
['DefaultFunctions', 'invalid', ['FUNC_CHAR' => '', 'FUNC_DATE' => '', 'FUNC_NUMBER' => '', 'FUNC_SPATIAL' => 'GeomFromText', 'FUNC_UUID' => 'UUID', 'first_timestamp' => 'NOW']],
['maxRowPlotLimit', 0, 500],
@@ -1453,6 +1444,26 @@ class SettingsTest extends TestCase
yield 'valid value with type coercion' => [0, false];
}
+ /** @param mixed[] $expected */
+ #[DataProvider('valuesForDebugProvider')]
+ public function testDebug(mixed $actual, array $expected): void
+ {
+ $settings = new Settings(['DBG' => $actual]);
+ $settingsArray = $settings->asArray();
+ $expectedDebug = new Debug($expected);
+ self::assertEquals($expectedDebug, $settings->debug);
+ self::assertSame($expectedDebug->asArray(), $settingsArray['DBG']);
+ }
+
+ /** @return iterable */
+ public static function valuesForDebugProvider(): iterable
+ {
+ yield 'null value' => [null, []];
+ yield 'valid value' => [[], []];
+ yield 'valid value 2' => [['demo' => true], ['demo' => true]];
+ yield 'invalid value' => ['invalid', []];
+ }
+
/** @param array{internal: int, human: string} $expected */
#[DataProvider('valuesForMysqlMinVersionProvider')]
public function testMysqlMinVersion(mixed $actual, array $expected): void
diff --git a/tests/unit/DatabaseInterfaceTest.php b/tests/unit/DatabaseInterfaceTest.php
index 2044bbcbbc..7833cda269 100644
--- a/tests/unit/DatabaseInterfaceTest.php
+++ b/tests/unit/DatabaseInterfaceTest.php
@@ -276,7 +276,6 @@ class DatabaseInterfaceTest extends AbstractTestCase
$config = Config::getInstance();
$config->selectedServer['DisableIS'] = false;
- $config->settings['DBG']['sql'] = false;
self::assertSame(
'utf8_general_ci',
@@ -300,8 +299,10 @@ class DatabaseInterfaceTest extends AbstractTestCase
public function testGetServerCollation(): void
{
$dbi = $this->createDatabaseInterface();
- Config::getInstance()->settings['DBG']['sql'] = true;
+ $config = Config::getInstance();
+ $config->config->debug->sql = true;
self::assertSame('utf8_general_ci', $dbi->getServerCollation());
+ $config->config->debug->sql = false;
}
/**
diff --git a/tests/unit/Dbal/DbiDummyTest.php b/tests/unit/Dbal/DbiDummyTest.php
index 0a94692ff0..ad0fcca7e2 100644
--- a/tests/unit/Dbal/DbiDummyTest.php
+++ b/tests/unit/Dbal/DbiDummyTest.php
@@ -31,7 +31,6 @@ class DbiDummyTest extends AbstractTestCase
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
DatabaseInterface::$instance = $this->dbi;
$config = Config::getInstance();
- $config->settings['DBG']['sql'] = false;
$config->settings['IconvExtraParams'] = '';
}
diff --git a/tests/unit/FooterTest.php b/tests/unit/FooterTest.php
index 665a2dd25a..beffc7b3ba 100644
--- a/tests/unit/FooterTest.php
+++ b/tests/unit/FooterTest.php
@@ -68,7 +68,8 @@ class FooterTest extends AbstractTestCase
#[Group('medium')]
public function testGetDebugMessage(): void
{
- Config::getInstance()->settings['DBG']['sql'] = true;
+ $config = Config::getInstance();
+ $config->config->debug->sql = true;
$_SESSION['debug']['queries'] = [
['count' => 1, 'time' => 0.2, 'query' => 'SELECT * FROM `pma_bookmark` WHERE 1'],
['count' => 1, 'time' => 2.5, 'query' => 'SELECT * FROM `db` WHERE 1'],
@@ -79,6 +80,7 @@ class FooterTest extends AbstractTestCase
. '{"count":1,"time":2.5,"query":"SELECT * FROM `db` WHERE 1"}]}',
$this->object->getDebugMessage(),
);
+ $config->config->debug->sql = false;
}
/**
diff --git a/tests/unit/Replication/ReplicationGuiTest.php b/tests/unit/Replication/ReplicationGuiTest.php
index 7a5ab71736..8105bde276 100644
--- a/tests/unit/Replication/ReplicationGuiTest.php
+++ b/tests/unit/Replication/ReplicationGuiTest.php
@@ -44,7 +44,6 @@ class ReplicationGuiTest extends AbstractTestCase
$config->settings['ShowSQL'] = true;
$config->settings['TableNavigationLinksMode'] = 'icons';
$config->settings['LimitChars'] = 100;
- $config->settings['DBG']['sql'] = false;
$config->settings['ShowHint'] = true;
Current::$table = 'table';
diff --git a/tests/unit/Stubs/DbiDummy.php b/tests/unit/Stubs/DbiDummy.php
index 6343d0e808..35ff216e97 100644
--- a/tests/unit/Stubs/DbiDummy.php
+++ b/tests/unit/Stubs/DbiDummy.php
@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests\Stubs;
-use PhpMyAdmin\Config;
use PhpMyAdmin\Config\Settings\Server;
use PhpMyAdmin\Dbal\Connection;
use PhpMyAdmin\Dbal\DbiExtension;
@@ -2256,8 +2255,5 @@ class DbiDummy implements DbiExtension
],
],
];
-
- /* Some basic setup for dummy driver */
- Config::getInstance()->settings['DBG']['sql'] = false;
}
}
diff --git a/tests/unit/TransformationsTest.php b/tests/unit/TransformationsTest.php
index 3f2fe9520a..352c6b1b2b 100644
--- a/tests/unit/TransformationsTest.php
+++ b/tests/unit/TransformationsTest.php
@@ -41,7 +41,6 @@ class TransformationsTest extends AbstractTestCase
$config->selectedServer['table_info'] = '';
$config->selectedServer['table_coords'] = '';
$config->selectedServer['column_info'] = 'column_info';
- $config->settings['DBG']['sql'] = false;
$this->transformations = new Transformations();
}
diff --git a/tests/unit/TwoFactorTest.php b/tests/unit/TwoFactorTest.php
index f30d433ec5..69375876c1 100644
--- a/tests/unit/TwoFactorTest.php
+++ b/tests/unit/TwoFactorTest.php
@@ -46,7 +46,6 @@ class TwoFactorTest extends AbstractTestCase
Current::$table = 'table';
$config = Config::getInstance();
$config->selectedServer['DisableIS'] = false;
- $config->settings['DBG'] = ['simple2fa' => false, 'sql' => false];
$config->settings['NaturalOrder'] = true;
$this->initStorageConfigAndData();
}
@@ -175,11 +174,11 @@ class TwoFactorTest extends AbstractTestCase
{
$request = new ServerRequest(self::createStub(ServerRequestInterface::class));
$config = Config::getInstance();
- $config->settings['DBG']['simple2fa'] = true;
+ $config->config->debug->simple2fa = true;
$object = $this->getTwoFactorAndLoadConfig('user', ['type' => 'db', 'backend' => 'simple']);
$backend = $object->getBackend();
self::assertSame('simple', $backend::$id);
- $config->settings['DBG']['simple2fa'] = false;
+ $config->config->debug->simple2fa = false;
unset($_POST['2fa_confirm']);
self::assertFalse($object->check($request, true));
@@ -204,7 +203,7 @@ class TwoFactorTest extends AbstractTestCase
{
$request = new ServerRequest(self::createStub(ServerRequestInterface::class));
$config = Config::getInstance();
- $config->settings['DBG']['simple2fa'] = true;
+ $config->config->debug->simple2fa = true;
$object = $this->getTwoFactorAndLoadConfig('user', null);
$this->dummyDbi->assertAllQueriesConsumed();
@@ -229,7 +228,7 @@ class TwoFactorTest extends AbstractTestCase
$this->initStorageConfigAndData();// Needs a re-init
- $config->settings['DBG']['simple2fa'] = false;
+ $config->config->debug->simple2fa = false;
$object = $this->getTwoFactorAndLoadConfig('user', null);
self::assertFalse($object->configure($request, 'simple'));
$this->dummyDbi->assertAllQueriesConsumed();
@@ -484,13 +483,13 @@ class TwoFactorTest extends AbstractTestCase
public function testBackends(): void
{
$config = Config::getInstance();
- $config->settings['DBG']['simple2fa'] = true;
+ $config->config->debug->simple2fa = true;
$object = $this->getTwoFactorAndLoadConfig('user', null);
$backends = $object->getAllBackends();
self::assertCount(
count($object->getAvailable()) + 1,
$backends,
);
- $config->settings['DBG']['simple2fa'] = false;
+ $config->config->debug->simple2fa = false;
}
}