Visitar URL original
Merge pull request #18639 from kamil-tekiela/Fix-SA-issues · phpmyadmin/phpmyadmin@b19648b · GitHub
Skip to content

Commit b19648b

Browse files
Merge pull request #18639 from kamil-tekiela/Fix-SA-issues
Fix SA issues from PR #18638
2 parents 719ec0a + d4fb656 commit b19648b

8 files changed

Lines changed: 11 additions & 112 deletions

File tree

‎libraries/classes/ConfigStorage/Relation.php‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,11 @@ private function checkRelationsParam(): array
246246
$config = Config::getInstance();
247247
if (
248248
$GLOBALS['server'] == 0
249-
|| empty($config->selectedServer['pmadb'])
249+
|| $config->selectedServer['pmadb'] === ''
250250
|| ! $this->dbi->selectDb($config->selectedServer['pmadb'], Connection::TYPE_CONTROL)
251251
) {
252252
// No server selected -> no bookmark table
253-
// we return the array with the falses in it,
254-
// to avoid some 'Uninitialized string offset' errors later
255-
$config->selectedServer['pmadb'] = false;
253+
$config->selectedServer['pmadb'] = '';
256254

257255
return $relationParams;
258256
}
@@ -269,7 +267,6 @@ private function checkRelationsParam(): array
269267

270268
if ($relationParamsFilled === null) {
271269
// query failed ... ?
272-
//\PhpMyAdmin\Config::getInstance()->selectedServer['pmadb'] = false;
273270
return $relationParams;
274271
}
275272

@@ -1732,17 +1729,15 @@ public function initRelationParamsCache(): void
17321729
$config = Config::getInstance();
17331730
$storageDbName = $config->selectedServer['pmadb'] ?? '';
17341731
// Use "phpmyadmin" as a default database name to check to keep the behavior consistent
1735-
$storageDbName = is_string($storageDbName) && $storageDbName !== '' ? $storageDbName : 'phpmyadmin';
1732+
$storageDbName = $storageDbName !== '' ? $storageDbName : 'phpmyadmin';
17361733

17371734
// This will make users not having explicitly listed databases
17381735
// have config values filled by the default phpMyAdmin storage table name values
17391736
$this->fixPmaTables($storageDbName, false);
17401737

17411738
// This global will be changed if fixPmaTables did find one valid table
1742-
$storageDbName = $config->selectedServer['pmadb'] ?? '';
1743-
17441739
// Empty means that until now no pmadb was found eligible
1745-
if (! empty($storageDbName)) {
1740+
if ($config->selectedServer['pmadb'] !== '') {
17461741
return;
17471742
}
17481743

‎libraries/classes/Database/CentralColumns.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function __construct(private DatabaseInterface $dbi)
6464
$this->user = $config->selectedServer['user'];
6565
$this->maxRows = (int) $GLOBALS['cfg']['MaxRows'];
6666
$this->charEditing = $GLOBALS['cfg']['CharEditing'];
67-
$this->disableIs = (bool) $config->selectedServer['DisableIS'];
67+
$this->disableIs = $config->selectedServer['DisableIS'];
6868

6969
$this->relation = new Relation($this->dbi);
7070
$this->template = new Template();

‎libraries/classes/IpAllowDeny.php‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use function hexdec;
1616
use function inet_pton;
1717
use function ip2long;
18-
use function is_array;
1918
use function mb_strpos;
2019
use function mb_strtolower;
2120
use function mb_substr;
@@ -247,14 +246,7 @@ private function allowDeny(string $type): bool
247246
$username = $config->selectedServer['user'];
248247

249248
// copy rule database
250-
if (isset($config->selectedServer['AllowDeny']['rules'])) {
251-
$rules = $config->selectedServer['AllowDeny']['rules'];
252-
if (! is_array($rules)) {
253-
$rules = [];
254-
}
255-
} else {
256-
$rules = [];
257-
}
249+
$rules = $config->selectedServer['AllowDeny']['rules'];
258250

259251
// lookup table for some name shortcuts
260252
$shortcuts = ['all' => '0.0.0.0/0', 'localhost' => '127.0.0.1/8'];

‎libraries/classes/Plugins/Auth/AuthenticationSignon.php‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public function showLoginForm(): never
6161
public function setCookieParams(array|null $sessionCookieParams = null): void
6262
{
6363
/* Session cookie params from config */
64-
if ($sessionCookieParams === null) {
65-
$sessionCookieParams = (array) Config::getInstance()->selectedServer['SignonCookieParams'];
66-
}
64+
$sessionCookieParams ??= Config::getInstance()->selectedServer['SignonCookieParams'];
6765

6866
foreach (['lifetime', 'path', 'domain', 'secure', 'httponly'] as $key) {
6967
if (isset($sessionCookieParams[$key])) {

‎libraries/classes/Server/Status/Data.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public function __construct(private DatabaseInterface $dbi, private Config $conf
382382
// Set all class properties
383383
$this->dbIsLocal = false;
384384
// can be null if $cfg['ServerDefault'] = 0;
385-
$serverHostToLower = mb_strtolower((string) $config->selectedServer['host']);
385+
$serverHostToLower = mb_strtolower($config->selectedServer['host']);
386386
if (
387387
$serverHostToLower === 'localhost'
388388
|| $config->selectedServer['host'] === '127.0.0.1'

‎libraries/classes/Table.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ protected function saveUiPrefsToDb(UiPreferencesFeature $uiPreferencesFeature):
16821682
// maximum rows
16831683
$sqlQuery = 'SELECT COUNT(*) FROM ' . $table;
16841684
$rowsCount = (int) $this->dbi->fetchValue($sqlQuery);
1685-
$maxRows = (int) $config->selectedServer['MaxTableUiprefs'];
1685+
$maxRows = $config->selectedServer['MaxTableUiprefs'];
16861686
if ($rowsCount > $maxRows) {
16871687
$numRowsToDelete = $rowsCount - $maxRows;
16881688
$sqlQuery = ' DELETE FROM ' . $table . ' ORDER BY last_update ASC LIMIT ' . $numRowsToDelete;

‎phpstan-baseline.neon‎

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,6 @@ parameters:
11301130
count: 1
11311131
path: libraries/classes/ConfigStorage/Relation.php
11321132

1133-
-
1134-
message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#"
1135-
count: 1
1136-
path: libraries/classes/ConfigStorage/Relation.php
1137-
11381133
-
11391134
message: "#^Cannot access an offset on mixed\\.$#"
11401135
count: 1
@@ -1247,7 +1242,7 @@ parameters:
12471242

12481243
-
12491244
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
1250-
count: 23
1245+
count: 21
12511246
path: libraries/classes/ConfigStorage/Relation.php
12521247

12531248
-
@@ -1415,11 +1410,6 @@ parameters:
14151410
count: 2
14161411
path: libraries/classes/ConfigStorage/Relation.php
14171412

1418-
-
1419-
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, \\.\\.\\.\\}\\.$#"
1420-
count: 1
1421-
path: libraries/classes/ConfigStorage/Relation.php
1422-
14231413
-
14241414
message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#"
14251415
count: 3
@@ -9670,11 +9660,6 @@ parameters:
96709660
count: 4
96719661
path: libraries/classes/Database/CentralColumns.php
96729662

9673-
-
9674-
message: "#^Casting to bool something that's already bool\\.$#"
9675-
count: 1
9676-
path: libraries/classes/Database/CentralColumns.php
9677-
96789663
-
96799664
message: "#^Foreach overwrites \\$table with its value variable\\.$#"
96809665
count: 2
@@ -13965,11 +13950,6 @@ parameters:
1396513950
count: 1
1396613951
path: libraries/classes/IpAllowDeny.php
1396713952

13968-
-
13969-
message: "#^Call to function is_array\\(\\) with array\\<string\\> will always evaluate to true\\.$#"
13970-
count: 1
13971-
path: libraries/classes/IpAllowDeny.php
13972-
1397313953
-
1397413954
message: "#^Only booleans are allowed in an if condition, int\\|false given\\.$#"
1397513955
count: 3
@@ -15840,11 +15820,6 @@ parameters:
1584015820
count: 1
1584115821
path: libraries/classes/Plugins/Auth/AuthenticationSignon.php
1584215822

15843-
-
15844-
message: "#^Casting to array\\<string, bool\\|int\\|string\\> something that's already array\\<string, bool\\|int\\<0, max\\>\\|string\\>\\.$#"
15845-
count: 1
15846-
path: libraries/classes/Plugins/Auth/AuthenticationSignon.php
15847-
1584815823
-
1584915824
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
1585015825
count: 2
@@ -20105,11 +20080,6 @@ parameters:
2010520080
count: 4
2010620081
path: libraries/classes/Server/Status/Data.php
2010720082

20108-
-
20109-
message: "#^Casting to string something that's already string\\.$#"
20110-
count: 1
20111-
path: libraries/classes/Server/Status/Data.php
20112-
2011320083
-
2011420084
message: "#^Only booleans are allowed in an if condition, mixed given\\.$#"
2011520085
count: 2
@@ -21145,11 +21115,6 @@ parameters:
2114521115
count: 3
2114621116
path: libraries/classes/Table.php
2114721117

21148-
-
21149-
message: "#^Casting to int something that's already int\\<1, max\\>\\.$#"
21150-
count: 1
21151-
path: libraries/classes/Table.php
21152-
2115321118
-
2115421119
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
2115521120
count: 20

‎psalm-baseline.xml‎

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.14.1@b9d355e0829c397b9b3b47d0c0ed042a8a70284d">
2+
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
33
<file src="libraries/classes/Advisory/Advisor.php">
44
<ArgumentTypeCoercion>
55
<code>$pattern</code>
@@ -607,15 +607,9 @@
607607
</ReferenceReusedFromConfusingScope>
608608
</file>
609609
<file src="libraries/classes/ConfigStorage/Relation.php">
610-
<DocblockTypeContradiction>
611-
<code><![CDATA['phpmyadmin']]></code>
612-
</DocblockTypeContradiction>
613610
<InvalidArgument>
614611
<code><![CDATA[usort($tables, 'strnatcasecmp')]]></code>
615612
</InvalidArgument>
616-
<InvalidPropertyAssignmentValue>
617-
<code><![CDATA[$config->selectedServer]]></code>
618-
</InvalidPropertyAssignmentValue>
619613
<InvalidReturnStatement>
620614
<code>$tableNameReplacements</code>
621615
</InvalidReturnStatement>
@@ -751,9 +745,6 @@
751745
<code><![CDATA[isset($GLOBALS['cfg']['ForeignKeyDropdownOrder'][1])
752746
&& is_scalar($GLOBALS['cfg']['ForeignKeyDropdownOrder'][1])]]></code>
753747
</RedundantCondition>
754-
<RedundantConditionGivenDocblockType>
755-
<code>is_string($storageDbName)</code>
756-
</RedundantConditionGivenDocblockType>
757748
</file>
758749
<file src="libraries/classes/ConfigStorage/UserGroups.php">
759750
<DeprecatedMethod>
@@ -4640,9 +4631,6 @@
46404631
<RedundantCast>
46414632
<code><![CDATA[(int) $GLOBALS['cfg']['MaxRows']]]></code>
46424633
</RedundantCast>
4643-
<RedundantCastGivenDocblockType>
4644-
<code><![CDATA[(bool) $config->selectedServer['DisableIS']]]></code>
4645-
</RedundantCastGivenDocblockType>
46464634
</file>
46474635
<file src="libraries/classes/Database/Designer.php">
46484636
<DeprecatedMethod>
@@ -7075,9 +7063,6 @@
70757063
</RedundantCast>
70767064
</file>
70777065
<file src="libraries/classes/IpAllowDeny.php">
7078-
<DocblockTypeContradiction>
7079-
<code>is_array($rules)</code>
7080-
</DocblockTypeContradiction>
70817066
<InvalidOperand>
70827067
<code>$regs[5]</code>
70837068
</InvalidOperand>
@@ -8111,9 +8096,6 @@
81118096
<code><![CDATA[$config->selectedServer]]></code>
81128097
<code><![CDATA[array_merge($config->selectedServer, $singleSignonCfgUpdate)]]></code>
81138098
</MixedPropertyTypeCoercion>
8114-
<RedundantCastGivenDocblockType>
8115-
<code><![CDATA[(array) Config::getInstance()->selectedServer['SignonCookieParams']]]></code>
8116-
</RedundantCastGivenDocblockType>
81178099
</file>
81188100
<file src="libraries/classes/Plugins/AuthenticationPlugin.php">
81198101
<ArgumentTypeCoercion>
@@ -9448,23 +9430,13 @@
94489430
<code>count</code>
94499431
<code>getName</code>
94509432
</MixedMethodCall>
9451-
<MixedPropertyFetch>
9452-
<code><![CDATA[$xml->children('office', true)->{'body'}->{'spreadsheet'}]]></code>
9453-
</MixedPropertyFetch>
94549433
<PossiblyNullArgument>
9455-
<code>$cellAttrs</code>
94569434
<code>$sheets</code>
9457-
<code>$text</code>
94589435
</PossiblyNullArgument>
94599436
<PossiblyNullArrayAccess>
9460-
<code><![CDATA[$attr['number-columns-repeated']]]></code>
9461-
<code><![CDATA[$attr['number-columns-repeated']]]></code>
94629437
<code><![CDATA[$tblAttr['name']]]></code>
94639438
<code><![CDATA[$tblAttr['name']]]></code>
94649439
</PossiblyNullArrayAccess>
9465-
<PossiblyNullReference>
9466-
<code>count</code>
9467-
</PossiblyNullReference>
94689440
<PossiblyUnusedReturnValue>
94699441
<code>string[]</code>
94709442
</PossiblyUnusedReturnValue>
@@ -9596,39 +9568,22 @@
95969568
<MixedAssignment>
95979569
<code><![CDATA[$GLOBALS['timeout_passed']]]></code>
95989570
<code>$attrs</code>
9599-
<code>$dbAttr</code>
96009571
<code>$rowAttr</code>
96019572
<code>$tblAttr</code>
96029573
<code>$v2</code>
96039574
<code>$val2</code>
96049575
<code>$val3</code>
96059576
</MixedAssignment>
96069577
<MixedMethodCall>
9607-
<code>$v1</code>
9608-
<code>$v1</code>
9609-
<code>$val1</code>
9610-
<code>$val1</code>
9611-
<code>$val2</code>
9612-
<code>$val2</code>
96139578
<code>attributes</code>
96149579
<code>attributes</code>
96159580
<code>attributes</code>
96169581
</MixedMethodCall>
9617-
<MixedPropertyFetch>
9618-
<code><![CDATA[$xml->children($namespaces['pma'] ?? null)
9619-
->{'structure_schemas'}->{'database'}]]></code>
9620-
</MixedPropertyFetch>
96219582
<PossiblyNullArrayAccess>
9622-
<code><![CDATA[$attrs['name']]]></code>
96239583
<code><![CDATA[$dbAttr['charset']]]></code>
96249584
<code><![CDATA[$dbAttr['collation']]]></code>
96259585
<code><![CDATA[$dbAttr['name']]]></code>
96269586
<code><![CDATA[$dbAttr['name']]]></code>
9627-
<code><![CDATA[$rowAttr['name']]]></code>
9628-
<code><![CDATA[$rowAttr['name']]]></code>
9629-
<code><![CDATA[$tblAttr['name']]]></code>
9630-
<code><![CDATA[$tblAttr['name']]]></code>
9631-
<code><![CDATA[$tblAttr['name']]]></code>
96329587
</PossiblyNullArrayAccess>
96339588
<PossiblyNullReference>
96349589
<code>attributes</code>
@@ -11377,9 +11332,6 @@
1137711332
<code>$a</code>
1137811333
<code>$b</code>
1137911334
</PossiblyUnusedParam>
11380-
<RedundantCastGivenDocblockType>
11381-
<code><![CDATA[(string) $config->selectedServer['host']]]></code>
11382-
</RedundantCastGivenDocblockType>
1138311335
<UnusedProperty>
1138411336
<code>$dbi</code>
1138511337
</UnusedProperty>
@@ -12070,9 +12022,6 @@
1207012022
<PossiblyUnusedReturnValue>
1207112023
<code>true|Message</code>
1207212024
</PossiblyUnusedReturnValue>
12073-
<RedundantCastGivenDocblockType>
12074-
<code><![CDATA[(int) $config->selectedServer['MaxTableUiprefs']]]></code>
12075-
</RedundantCastGivenDocblockType>
1207612025
<ReferenceConstraintViolation>
1207712026
<code>return $sqlQuery;</code>
1207812027
</ReferenceConstraintViolation>

0 commit comments

Comments
 (0)