Skip to content

Commit 1eff7e5

Browse files
Merge pull request #20136 from kamil-tekiela/Fix-Config-tests
Fix config in tests
2 parents 7251034 + 57d71de commit 1eff7e5

21 files changed

Lines changed: 46 additions & 159 deletions

phpstan-baseline.neon

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14562,12 +14562,6 @@ parameters:
1456214562
count: 1
1456314563
path: tests/unit/Controllers/Operations/TableControllerTest.php
1456414564

14565-
-
14566-
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, \.\.\.\}\.$#'
14567-
identifier: assign.propertyType
14568-
count: 1
14569-
path: tests/unit/Controllers/Operations/TableControllerTest.php
14570-
1457114565
-
1457214566
message: '''
1457314567
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -15423,7 +15417,7 @@ parameters:
1542315417
Use dependency injection instead\.$#
1542415418
'''
1542515419
identifier: staticMethod.deprecated
15426-
count: 10
15420+
count: 9
1542715421
path: tests/unit/Display/ResultsTest.php
1542815422

1542915423
-
@@ -15492,12 +15486,6 @@ parameters:
1549215486
count: 4
1549315487
path: tests/unit/Display/ResultsTest.php
1549415488

15495-
-
15496-
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, \.\.\.\}\.$#'
15497-
identifier: assign.propertyType
15498-
count: 3
15499-
path: tests/unit/Display/ResultsTest.php
15500-
1550115489
-
1550215490
message: '''
1550315491
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16548,7 +16536,7 @@ parameters:
1654816536
-
1654916537
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, \.\.\.\}\.$#'
1655016538
identifier: assign.propertyType
16551-
count: 2
16539+
count: 1
1655216540
path: tests/unit/Server/SelectTest.php
1655316541

1655416542
-
@@ -16734,21 +16722,6 @@ parameters:
1673416722
count: 2
1673516723
path: tests/unit/Tracking/TrackingTest.php
1673616724

16737-
-
16738-
message: '''
16739-
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
16740-
Use dependency injection instead\.$#
16741-
'''
16742-
identifier: staticMethod.deprecated
16743-
count: 1
16744-
path: tests/unit/TransformationsTest.php
16745-
16746-
-
16747-
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''\}\.$#'
16748-
identifier: assign.propertyType
16749-
count: 1
16750-
path: tests/unit/TransformationsTest.php
16751-
1675216725
-
1675316726
message: '''
1675416727
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
@@ -16842,7 +16815,7 @@ parameters:
1684216815
Use dependency injection instead\.$#
1684316816
'''
1684416817
identifier: staticMethod.deprecated
16845-
count: 4
16818+
count: 3
1684616819
path: tests/unit/UtilTest.php
1684716820

1684816821
-
@@ -16965,7 +16938,7 @@ parameters:
1696516938
Use dependency injection instead\.$#
1696616939
'''
1696716940
identifier: staticMethod.deprecated
16968-
count: 5
16941+
count: 4
1696916942
path: tests/unit/VersionInformationTest.php
1697016943

1697116944
-

psalm-baseline.xml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9366,9 +9366,6 @@
93669366
<DeprecatedMethod>
93679367
<code><![CDATA[Config::getInstance()]]></code>
93689368
</DeprecatedMethod>
9369-
<InvalidPropertyAssignmentValue>
9370-
<code><![CDATA[$config->settings]]></code>
9371-
</InvalidPropertyAssignmentValue>
93729369
</file>
93739370
<file src="tests/unit/Controllers/PhpInfoControllerTest.php">
93749371
<DeprecatedMethod>
@@ -9855,7 +9852,6 @@
98559852
<code><![CDATA[Config::getInstance()]]></code>
98569853
<code><![CDATA[Config::getInstance()]]></code>
98579854
<code><![CDATA[Config::getInstance()]]></code>
9858-
<code><![CDATA[Config::getInstance()]]></code>
98599855
</DeprecatedMethod>
98609856
<DocblockTypeContradiction>
98619857
<code><![CDATA[assertSame]]></code>
@@ -9923,11 +9919,6 @@
99239919
<code><![CDATA[testSetConfigParamsForDisplayTable]]></code>
99249920
<code><![CDATA[testSetConfigParamsForDisplayTable]]></code>
99259921
</PossiblyInvalidArgument>
9926-
<PropertyTypeCoercion>
9927-
<code><![CDATA[$config->settings]]></code>
9928-
<code><![CDATA[Config::getInstance()->settings]]></code>
9929-
<code><![CDATA[Config::getInstance()->settings]]></code>
9930-
</PropertyTypeCoercion>
99319922
</file>
99329923
<file src="tests/unit/EncodingTest.php">
99339924
<DeprecatedMethod>
@@ -10537,14 +10528,6 @@
1053710528
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
1053810529
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
1053910530
</DeprecatedMethod>
10540-
<InvalidPropertyAssignmentValue>
10541-
<code><![CDATA[$config->settings]]></code>
10542-
<code><![CDATA[$config->settings]]></code>
10543-
<code><![CDATA[$config->settings]]></code>
10544-
<code><![CDATA[$config->settings]]></code>
10545-
<code><![CDATA[$config->settings]]></code>
10546-
<code><![CDATA[$config->settings]]></code>
10547-
</InvalidPropertyAssignmentValue>
1054810531
</file>
1054910532
<file src="tests/unit/Routing/RoutingTest.php">
1055010533
<DeprecatedMethod>
@@ -10591,12 +10574,6 @@
1059110574
</InvalidArrayOffset>
1059210575
<InvalidPropertyAssignmentValue>
1059310576
<code><![CDATA[$config->settings]]></code>
10594-
<code><![CDATA[$config->settings]]></code>
10595-
<code><![CDATA[$config->settings]]></code>
10596-
<code><![CDATA[$config->settings]]></code>
10597-
<code><![CDATA[$config->settings]]></code>
10598-
<code><![CDATA[$config->settings]]></code>
10599-
<code><![CDATA[$config->settings]]></code>
1060010577
</InvalidPropertyAssignmentValue>
1060110578
<PossiblyInvalidArgument>
1060210579
<code><![CDATA[$server['only_db']]]></code>
@@ -10739,12 +10716,6 @@
1073910716
</MixedArrayAccess>
1074010717
</file>
1074110718
<file src="tests/unit/TransformationsTest.php">
10742-
<DeprecatedMethod>
10743-
<code><![CDATA[Config::getInstance()]]></code>
10744-
</DeprecatedMethod>
10745-
<InvalidPropertyAssignmentValue>
10746-
<code><![CDATA[['ServerDefault' => 1, 'ActionLinksMode' => 'icons']]]></code>
10747-
</InvalidPropertyAssignmentValue>
1074810719
<PossiblyInvalidArgument>
1074910720
<code><![CDATA[testFixup]]></code>
1075010721
<code><![CDATA[testFixup]]></code>
@@ -10819,7 +10790,6 @@
1081910790
<code><![CDATA[Config::getInstance()]]></code>
1082010791
<code><![CDATA[Config::getInstance()]]></code>
1082110792
<code><![CDATA[Config::getInstance()]]></code>
10822-
<code><![CDATA[Config::getInstance()]]></code>
1082310793
</DeprecatedMethod>
1082410794
<MixedArgument>
1082510795
<code><![CDATA[$_SESSION['cache']['server_2_']]]></code>
@@ -10923,7 +10893,6 @@
1092310893
<code><![CDATA[Config::getInstance()]]></code>
1092410894
<code><![CDATA[Config::getInstance()]]></code>
1092510895
<code><![CDATA[Config::getInstance()]]></code>
10926-
<code><![CDATA[Config::getInstance()]]></code>
1092710896
</DeprecatedMethod>
1092810897
<InvalidPropertyAssignmentValue>
1092910898
<code><![CDATA[Config::getInstance()->settings]]></code>

src/ConfigStorage/Relation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ public function buildForeignDropdown(array $foreign, string $data, string $mode)
650650
mb_check_encoding($value, 'utf-8')
651651
&& preg_match('/[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\x9F]/u', $value) !== 1
652652
) {
653-
if (mb_strlen($value) <= $this->config->settings['LimitChars']) {
653+
if (mb_strlen($value) <= $this->config->config->limitChars) {
654654
// show as text if it's valid utf-8
655655
$value = htmlspecialchars($value);
656656
} else {
@@ -659,7 +659,7 @@ public function buildForeignDropdown(array $foreign, string $data, string $mode)
659659
mb_substr(
660660
$value,
661661
0,
662-
$this->config->settings['LimitChars'],
662+
$this->config->config->limitChars,
663663
) . '...',
664664
);
665665
}

src/Controllers/Database/StructureController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ private function displayTableList(array $replicaInfo): string
430430
),
431431
'num_favorite_tables' => $this->config->settings['NumFavoriteTables'],
432432
'properties_num_columns' => $this->config->config->PropertiesNumColumns,
433-
'limit_chars' => $this->config->settings['LimitChars'],
433+
'limit_chars' => $this->config->config->limitChars,
434434
'show_charset' => $this->config->settings['ShowDbStructureCharset'],
435435
'show_comment' => $this->config->settings['ShowDbStructureComment'],
436436
'show_creation' => $this->config->settings['ShowDbStructureCreation'],

src/Controllers/HomeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public function __invoke(ServerRequest $request): Response
241241
'database_server' => $databaseServer,
242242
'web_server' => $webServer,
243243
'show_php_info' => $this->config->settings['ShowPhpInfo'],
244-
'is_version_checked' => $this->config->settings['VersionCheck'],
244+
'is_version_checked' => $this->config->config->VersionCheck,
245245
'phpmyadmin_major_version' => Version::SERIES,
246246
'config_storage_message' => $configStorageMessage ?? '',
247247
'has_theme_manager' => $this->config->settings['ThemeManager'],

src/Controllers/Operations/TableController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public function __invoke(ServerRequest $request): Response
443443

444444
$databaseList = [];
445445
$listDatabase = $this->dbi->getDatabaseList();
446-
if (count($listDatabase) <= $this->config->settings['MaxDbList']) {
446+
if (count($listDatabase) <= $this->config->config->MaxDbList) {
447447
$databaseList = $listDatabase->getList();
448448
}
449449

src/Controllers/Server/DatabasesController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public function __invoke(ServerRequest $request): Response
171171
'database_count' => $this->databaseCount,
172172
'pos' => $position,
173173
'url_params' => $urlParams,
174-
'max_db_list' => $this->config->settings['MaxDbList'],
174+
'max_db_list' => $this->config->config->MaxDbList,
175175
'has_primary_replication' => $primaryInfo['status'],
176176
'has_replica_replication' => $replicaInfo['status'],
177177
'is_drop_allowed' => $this->dbi->isSuperUser() || $this->config->settings['AllowUserDropDatabase'],

src/Dbal/DatabaseInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ public function getDatabasesFull(
646646
$sortOrder = strtoupper($sortOrder);
647647

648648
if ($limitCount === true) {
649-
$limitCount = $this->config->settings['MaxDbList'];
649+
$limitCount = $this->config->config->MaxDbList;
650650
}
651651

652652
$applyLimitAndOrderManual = true;

src/Display/Results.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ private function getCommentForRow(array $commentsMap, FieldMetadata $fieldsMeta)
11421142
'comments_map' => $commentsMap,
11431143
'column_name' => $fieldsMeta->name,
11441144
'table_name' => $fieldsMeta->table,
1145-
'limit_chars' => $this->config->settings['LimitChars'],
1145+
'limit_chars' => $this->config->config->limitChars,
11461146
]);
11471147
}
11481148

@@ -1267,12 +1267,12 @@ private function getSingleAndMultiSortUrls(
12671267
$tableName = $currentTable === '' ? '' : Util::backquote($currentTable) . '.';
12681268
$expression = $tableName . Util::backquote($currentColumn);
12691269
// Set the direction to the config value or perform SMART mode
1270-
if ($this->config->settings['Order'] === self::SMART_SORT_ORDER) {
1270+
if ($this->config->config->Order === self::SMART_SORT_ORDER) {
12711271
$direction = $fieldsMeta->isDateTimeType()
12721272
? self::DESCENDING_SORT_DIR
12731273
: self::ASCENDING_SORT_DIR;
12741274
} else {
1275-
$direction = $this->config->settings['Order'];
1275+
$direction = $this->config->config->Order;
12761276
}
12771277

12781278
$sortExpressions[] = new SortExpression(
@@ -2681,7 +2681,7 @@ private function getDataCellForNonNumericColumns(
26812681
// or transformation plugin is of non text type
26822682
// such as image
26832683
$isTypeBlob = $meta->isType(FieldMetadata::TYPE_BLOB);
2684-
$cfgProtectBinary = $this->config->settings['ProtectBinary'];
2684+
$cfgProtectBinary = $this->config->config->ProtectBinary;
26852685
if (
26862686
($meta->isBinary()
26872687
&& (
@@ -2702,7 +2702,7 @@ private function getDataCellForNonNumericColumns(
27022702
return $this->buildEmptyDisplay($class, $conditionField, $meta);
27032703
}
27042704

2705-
// Cut all fields to \PhpMyAdmin\Config::getInstance()->settings['LimitChars']
2705+
// Cut all fields to \PhpMyAdmin\Config::getInstance()->config->limitChars
27062706
// (unless it's a link-type transformation or binary)
27072707
$originalLength = 0;
27082708
$originalDataForWhereClause = $column;
@@ -3173,7 +3173,7 @@ private function getSortedColumnMessage(
31733173
mb_substr(
31743174
(string) $columnForFirstRow,
31753175
0,
3176-
$this->config->settings['LimitChars'],
3176+
$this->config->config->limitChars,
31773177
) . '...',
31783178
);
31793179

@@ -3199,7 +3199,7 @@ private function getSortedColumnMessage(
31993199
mb_substr(
32003200
(string) $columnForLastRow,
32013201
0,
3202-
$this->config->settings['LimitChars'],
3202+
$this->config->config->limitChars,
32033203
) . '...',
32043204
);
32053205

@@ -3760,10 +3760,10 @@ private function getRowData(
37603760
private function getPartialText(string $str): string
37613761
{
37623762
if (
3763-
mb_strlen($str) > $this->config->settings['LimitChars']
3763+
mb_strlen($str) > $this->config->config->limitChars
37643764
&& $_SESSION['tmpval']['pftext'] === self::DISPLAY_PARTIAL_TEXT
37653765
) {
3766-
return mb_substr($str, 0, $this->config->settings['LimitChars']) . '...';
3766+
return mb_substr($str, 0, $this->config->config->limitChars) . '...';
37673767
}
37683768

37693769
return $str;

src/Util.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,13 +1006,13 @@ public static function extractColumnSpec(string $columnSpecification): array
10061006
// for the case ENUM('&#8211;','&ldquo;')
10071007
$displayedType = htmlspecialchars($printType, ENT_COMPAT);
10081008
$config = Config::getInstance();
1009-
if (mb_strlen($printType) > $config->settings['LimitChars']) {
1009+
if (mb_strlen($printType) > $config->config->limitChars) {
10101010
$displayedType = '<abbr title="' . htmlspecialchars($printType) . '">';
10111011
$displayedType .= htmlspecialchars(
10121012
mb_substr(
10131013
$printType,
10141014
0,
1015-
$config->settings['LimitChars'],
1015+
$config->config->limitChars,
10161016
) . '...',
10171017
ENT_COMPAT,
10181018
);

0 commit comments

Comments
 (0)