Skip to content

Commit cdc2f37

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents e08cb8b + 7645611 commit cdc2f37

11 files changed

Lines changed: 89 additions & 71 deletions

File tree

‎.github/workflows/lint-and-analyse-php.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
php-version: ${{ matrix.php-version }}
2828

2929
- name: Validate composer.json and composer.lock
30-
run: composer validate
30+
run: composer validate --strict
3131

3232
- name: Install Composer dependencies
3333
# Allow the previous check to fail but not abort

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"nikic/fast-route": "^1.3",
6262
"phpmyadmin/motranslator": "^5.0",
6363
"phpmyadmin/shapefile": "^3.0.1",
64-
"phpmyadmin/sql-parser": "dev-master#a6da770b9d5b52b63262412dd76c0cef467abd23",
64+
"phpmyadmin/sql-parser": "^5.6.0",
6565
"phpmyadmin/twig-i18n-extension": "^4.0",
6666
"psr/http-factory": "^1.0",
6767
"psr/http-message": "^1.0",

‎libraries/classes/Controllers/Import/ImportController.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ public function __invoke(ServerRequest $request): void
306306
$GLOBALS['timestamp'] = time();
307307
if ($request->hasBodyParam('allow_interrupt')) {
308308
$GLOBALS['maximum_time'] = ini_get('max_execution_time');
309+
$GLOBALS['maximum_time'] -= 1; // Give 1 second for phpMyAdmin to exit nicely
309310
} else {
310311
$GLOBALS['maximum_time'] = 0;
311312
}

‎libraries/classes/Header.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ public function getDisplay(): string
381381
'show_hint' => $GLOBALS['cfg']['ShowHint'],
382382
'is_warnings_enabled' => $this->warningsEnabled,
383383
'is_menu_enabled' => $this->menuEnabled,
384+
'is_logged_in' => isset($GLOBALS['dbi']) ? $GLOBALS['dbi']->isConnected() : false,
384385
'menu' => $menu ?? '',
385386
'console' => $console,
386387
'messages' => $messages,

‎libraries/classes/Plugins/TwoFactor/Key.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Twig\Error\SyntaxError;
2020

2121
use function __;
22+
use function is_array;
2223
use function is_object;
2324
use function json_decode;
2425
use function json_encode;
@@ -41,7 +42,10 @@ class Key extends TwoFactorPlugin
4142
public function __construct(TwoFactor $twofactor)
4243
{
4344
parent::__construct($twofactor);
44-
if (isset($this->twofactor->config['settings']['registrations'])) {
45+
if (
46+
isset($this->twofactor->config['settings']['registrations'])
47+
&& is_array($this->twofactor->config['settings']['registrations'])
48+
) {
4549
return;
4650
}
4751

‎libraries/classes/TwoFactor.php‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use function class_exists;
2222
use function extension_loaded;
2323
use function in_array;
24+
use function is_array;
25+
use function is_string;
2426
use function ucfirst;
2527

2628
/**
@@ -31,7 +33,10 @@ class TwoFactor
3133
/** @var string */
3234
public $user;
3335

34-
/** @var array */
36+
/**
37+
* @var array
38+
* @psalm-var array{backend: string, settings: mixed[], type?: 'session'|'db'}
39+
*/
3540
public $config;
3641

3742
/** @var bool */
@@ -66,26 +71,27 @@ public function __construct($user)
6671
/**
6772
* Reads the configuration
6873
*
69-
* @return array
74+
* @psalm-return array{backend: string, settings: mixed[], type: 'session'|'db'}
7075
*/
71-
public function readConfig()
76+
public function readConfig(): array
7277
{
7378
$result = [];
7479
$config = $this->userPreferences->load();
75-
if (isset($config['config_data']['2fa'])) {
80+
if (isset($config['config_data']['2fa']) && is_array($config['config_data']['2fa'])) {
7681
$result = $config['config_data']['2fa'];
7782
}
7883

79-
$result['type'] = $config['type'];
80-
if (! isset($result['backend'])) {
81-
$result['backend'] = '';
84+
$backend = '';
85+
if (isset($result['backend']) && is_string($result['backend'])) {
86+
$backend = $result['backend'];
8287
}
8388

84-
if (! isset($result['settings'])) {
85-
$result['settings'] = [];
89+
$settings = [];
90+
if (isset($result['settings']) && is_array($result['settings'])) {
91+
$settings = $result['settings'];
8692
}
8793

88-
return $result;
94+
return ['backend' => $backend, 'settings' => $settings, 'type' => $config['type']];
8995
}
9096

9197
public function isWritable(): bool
@@ -261,18 +267,16 @@ public function save()
261267
*/
262268
public function configure($name): bool
263269
{
264-
$this->config = ['backend' => $name];
270+
$this->config = ['backend' => $name, 'settings' => []];
265271
if ($name === '') {
266272
$cls = $this->getBackendClass($name);
267-
$this->config['settings'] = [];
268273
$this->backend = new $cls($this);
269274
} else {
270275
if (! in_array($name, $this->available)) {
271276
return false;
272277
}
273278

274279
$cls = $this->getBackendClass($name);
275-
$this->config['settings'] = [];
276280
$this->backend = new $cls($this);
277281
if (! $this->backend->configure()) {
278282
return false;

‎libraries/classes/UserPreferences.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function pageInit(ConfigFile $cf): void
6969
* * mtime - last modification time
7070
* * type - 'db' (config read from pmadb) or 'session' (read from user session)
7171
*
72-
* @psalm-return array{config_data: array, mtime: int, type: 'session'|'db'}
72+
* @psalm-return array{config_data: mixed[], mtime: int, type: 'session'|'db'}
7373
*/
7474
public function load(): array
7575
{

‎phpstan-baseline.neon‎

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,11 @@ parameters:
14051405
count: 1
14061406
path: libraries/classes/Controllers/HomeController.php
14071407

1408+
-
1409+
message: "#^Binary operation \"\\-\\=\" between string\\|false and 1 results in an error\\.$#"
1410+
count: 1
1411+
path: libraries/classes/Controllers/Import/ImportController.php
1412+
14081413
-
14091414
message: "#^Cannot cast mixed to int\\.$#"
14101415
count: 2
@@ -6840,6 +6845,46 @@ parameters:
68406845
count: 1
68416846
path: libraries/classes/Plugins/TransformationsPlugin.php
68426847

6848+
-
6849+
message: "#^Parameter \\#1 \\$secret of method PragmaRX\\\\Google2FA\\\\Google2FA\\:\\:verifyKey\\(\\) expects string, mixed given\\.$#"
6850+
count: 1
6851+
path: libraries/classes/Plugins/TwoFactor/Application.php
6852+
6853+
-
6854+
message: "#^Parameter \\#3 \\$secret of method PragmaRX\\\\Google2FAQRCode\\\\Google2FA\\:\\:getQRCodeInline\\(\\) expects string, mixed given\\.$#"
6855+
count: 1
6856+
path: libraries/classes/Plugins/TwoFactor/Application.php
6857+
6858+
-
6859+
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
6860+
count: 1
6861+
path: libraries/classes/Plugins/TwoFactor/Key.php
6862+
6863+
-
6864+
message: "#^Cannot access an offset on mixed\\.$#"
6865+
count: 1
6866+
path: libraries/classes/Plugins/TwoFactor/Key.php
6867+
6868+
-
6869+
message: "#^Cannot access offset 'certificate' on mixed\\.$#"
6870+
count: 1
6871+
path: libraries/classes/Plugins/TwoFactor/Key.php
6872+
6873+
-
6874+
message: "#^Cannot access offset 'counter' on mixed\\.$#"
6875+
count: 2
6876+
path: libraries/classes/Plugins/TwoFactor/Key.php
6877+
6878+
-
6879+
message: "#^Cannot access offset 'keyHandle' on mixed\\.$#"
6880+
count: 1
6881+
path: libraries/classes/Plugins/TwoFactor/Key.php
6882+
6883+
-
6884+
message: "#^Cannot access offset 'publicKey' on mixed\\.$#"
6885+
count: 1
6886+
path: libraries/classes/Plugins/TwoFactor/Key.php
6887+
68436888
-
68446889
message: "#^Parameter \\#1 \\$registrations of static method CodeLts\\\\U2F\\\\U2FServer\\\\U2FServer\\:\\:makeAuthentication\\(\\) expects array\\<CodeLts\\\\U2F\\\\U2FServer\\\\stdClass\\>, array\\<stdClass\\> given\\.$#"
68456890
count: 1
@@ -7805,11 +7850,6 @@ parameters:
78057850
count: 1
78067851
path: libraries/classes/Sql.php
78077852

7808-
-
7809-
message: "#^Method PhpMyAdmin\\\\Sql\\:\\:getDetailedProfilingStats\\(\\) should return array\\<string, array\\|int\\> but returns array\\<string, array\\<int\\|string, mixed\\>\\|float\\|int\\>\\.$#"
7810-
count: 1
7811-
path: libraries/classes/Sql.php
7812-
78137853
-
78147854
message: "#^Method PhpMyAdmin\\\\Sql\\:\\:getHtmlForPreviousUpdateQuery\\(\\) has parameter \\$sqlData with no value type specified in iterable type array\\.$#"
78157855
count: 1
@@ -8675,11 +8715,6 @@ parameters:
86758715
count: 1
86768716
path: libraries/classes/TwoFactor.php
86778717

8678-
-
8679-
message: "#^Method PhpMyAdmin\\\\TwoFactor\\:\\:readConfig\\(\\) return type has no value type specified in iterable type array\\.$#"
8680-
count: 1
8681-
path: libraries/classes/TwoFactor.php
8682-
86838718
-
86848719
message: "#^Property PhpMyAdmin\\\\TwoFactor\\:\\:\\$available type has no value type specified in iterable type array\\.$#"
86858720
count: 1
@@ -8690,11 +8725,6 @@ parameters:
86908725
count: 2
86918726
path: libraries/classes/TwoFactor.php
86928727

8693-
-
8694-
message: "#^Property PhpMyAdmin\\\\TwoFactor\\:\\:\\$config type has no value type specified in iterable type array\\.$#"
8695-
count: 1
8696-
path: libraries/classes/TwoFactor.php
8697-
86988728
-
86998729
message: "#^Casting to string something that's already string\\.$#"
87008730
count: 1
@@ -8745,11 +8775,6 @@ parameters:
87458775
count: 1
87468776
path: libraries/classes/UserPreferences.php
87478777

8748-
-
8749-
message: "#^Method PhpMyAdmin\\\\UserPreferences\\:\\:load\\(\\) return type has no value type specified in iterable type array\\.$#"
8750-
count: 1
8751-
path: libraries/classes/UserPreferences.php
8752-
87538778
-
87548779
message: "#^Method PhpMyAdmin\\\\UserPreferences\\:\\:redirect\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
87558780
count: 1
@@ -11315,6 +11340,11 @@ parameters:
1131511340
count: 1
1131611341
path: test/classes/TwoFactorTest.php
1131711342

11343+
-
11344+
message: "#^Parameter \\#1 \\$secret of method PragmaRX\\\\Google2FA\\\\Google2FA\\:\\:oathTotp\\(\\) expects string, mixed given\\.$#"
11345+
count: 2
11346+
path: test/classes/TwoFactorTest.php
11347+
1131811348
-
1131911349
message: "#^Method PhpMyAdmin\\\\Tests\\\\TypesTest\\:\\:providerForGetTypeOperators\\(\\) return type has no value type specified in iterable type array\\.$#"
1132011350
count: 1

‎psalm-baseline.xml‎

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,9 @@
21232123
<InvalidArrayOffset occurrences="1">
21242124
<code>$GLOBALS['cfg']['AllowUserDropDatabase']</code>
21252125
</InvalidArrayOffset>
2126+
<InvalidOperand occurrences="1">
2127+
<code>$GLOBALS['maximum_time']</code>
2128+
</InvalidOperand>
21262129
<MixedArgument occurrences="13">
21272130
<code>$GLOBALS['cfg']['AllowUserDropDatabase']</code>
21282131
<code>$GLOBALS['cfg']['MemoryLimit']</code>
@@ -11513,14 +11516,6 @@
1151311516
<code>$secret</code>
1151411517
<code>$this-&gt;twofactor-&gt;config['settings']['secret']</code>
1151511518
</MixedArgument>
11516-
<MixedArrayAccess occurrences="2">
11517-
<code>$this-&gt;twofactor-&gt;config['settings']['secret']</code>
11518-
<code>$this-&gt;twofactor-&gt;config['settings']['secret']</code>
11519-
</MixedArrayAccess>
11520-
<MixedArrayAssignment occurrences="2">
11521-
<code>$this-&gt;twofactor-&gt;config['settings']['secret']</code>
11522-
<code>$this-&gt;twofactor-&gt;config['settings']['secret']</code>
11523-
</MixedArrayAssignment>
1152411519
<MixedAssignment occurrences="1">
1152511520
<code>$secret</code>
1152611521
</MixedAssignment>
@@ -11541,17 +11536,15 @@
1154111536
<code>$_SESSION['authenticationRequest']</code>
1154211537
<code>$_SESSION['registrationRequest']</code>
1154311538
</MixedArgument>
11544-
<MixedArrayAccess occurrences="5">
11539+
<MixedArrayAccess occurrences="4">
1154511540
<code>$data['certificate']</code>
1154611541
<code>$data['counter']</code>
1154711542
<code>$data['keyHandle']</code>
1154811543
<code>$data['publicKey']</code>
11549-
<code>$this-&gt;twofactor-&gt;config['settings']['registrations']</code>
1155011544
</MixedArrayAccess>
11551-
<MixedArrayAssignment occurrences="3">
11552-
<code>$this-&gt;twofactor-&gt;config['settings']['registrations']</code>
11553-
<code>$this-&gt;twofactor-&gt;config['settings']['registrations']</code>
11554-
<code>$this-&gt;twofactor-&gt;config['settings']['registrations']</code>
11545+
<MixedArrayAssignment occurrences="2">
11546+
<code>$this-&gt;twofactor-&gt;config['settings']['registrations'][$auth-&gt;index]</code>
11547+
<code>$this-&gt;twofactor-&gt;config['settings']['registrations'][]</code>
1155511548
</MixedArrayAssignment>
1155611549
<MixedArrayOffset occurrences="1">
1155711550
<code>$this-&gt;twofactor-&gt;config['settings']['registrations'][$auth-&gt;index]</code>
@@ -13731,22 +13724,12 @@
1373113724
<LessSpecificReturnStatement occurrences="1">
1373213725
<code>new $name($this)</code>
1373313726
</LessSpecificReturnStatement>
13734-
<MixedArgument occurrences="2">
13727+
<MixedArgument occurrences="1">
1373513728
<code>$name</code>
13736-
<code>$this-&gt;config['backend']</code>
1373713729
</MixedArgument>
13738-
<MixedArrayAssignment occurrences="3">
13739-
<code>$result['backend']</code>
13740-
<code>$result['settings']</code>
13741-
<code>$result['type']</code>
13742-
</MixedArrayAssignment>
13743-
<MixedAssignment occurrences="2">
13730+
<MixedAssignment occurrences="1">
1374413731
<code>$name</code>
13745-
<code>$result</code>
1374613732
</MixedAssignment>
13747-
<MixedInferredReturnType occurrences="1">
13748-
<code>array</code>
13749-
</MixedInferredReturnType>
1375013733
<MixedMethodCall occurrences="6">
1375113734
<code>$cls::getDescription()</code>
1375213735
<code>$cls::getName()</code>
@@ -13755,9 +13738,6 @@
1375513738
<code>new $cls($this)</code>
1375613739
<code>new $name($this)</code>
1375713740
</MixedMethodCall>
13758-
<MixedReturnStatement occurrences="1">
13759-
<code>$result</code>
13760-
</MixedReturnStatement>
1376113741
<MoreSpecificReturnType occurrences="1">
1376213742
<code>TwoFactorPlugin</code>
1376313743
</MoreSpecificReturnType>
@@ -15979,11 +15959,6 @@
1597915959
<code>$object-&gt;config['settings']['secret']</code>
1598015960
<code>$object-&gt;config['settings']['secret']</code>
1598115961
</MixedArgument>
15982-
<MixedArrayAccess occurrences="3">
15983-
<code>$object-&gt;config['settings']['secret']</code>
15984-
<code>$object-&gt;config['settings']['secret']</code>
15985-
<code>$object-&gt;config['settings']['secret']</code>
15986-
</MixedArrayAccess>
1598715962
</file>
1598815963
<file src="test/classes/TypesTest.php">
1598915964
<MixedInferredReturnType occurrences="5">

‎templates/header.twig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
{{ messages|raw }}
5555

5656
{{ recent_table|raw }}
57+
{%- if is_logged_in -%}
5758
{{ include('modals/preview_sql_modal.twig') }}
5859
{{ include('modals/enum_set_editor.twig') }}
5960
{{ include('modals/create_view.twig') }}
6061
{{ include('modals/change_password.twig') }}
62+
{%- endif -%}

0 commit comments

Comments
 (0)