Skip to content

Commit 342ab3f

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents 7c6e6aa + b0bcd99 commit 342ab3f

9 files changed

Lines changed: 82 additions & 82 deletions

File tree

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ phpMyAdmin - ChangeLog
1515
- issue #18106 Fix renaming database with a view
1616
- issue #18120 Fix bug with numerical tables during renaming database
1717
- issue #16851 Fix ($cfg['Order']) default column order doesn't have have any effect since phpMyAdmin 4.2.0
18+
- issue #18112 Fix open base dir warning on git version class
1819

1920
5.2.1 (2023-02-07)
2021
- issue #17522 Fix case where the routes cache file is invalid

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": "^5.6.0",
64+
"phpmyadmin/sql-parser": "dev-master#d906b5906100a6a4bc3c180900b50cbf1ff8ae0a",
6565
"phpmyadmin/twig-i18n-extension": "^4.0",
6666
"psr/http-factory": "^1.0",
6767
"psr/http-message": "^1.0",

libraries/classes/Controllers/HomeController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use function extension_loaded;
2929
use function file_exists;
3030
use function ini_get;
31+
use function is_string;
3132
use function mb_strlen;
3233
use function preg_match;
3334
use function sprintf;
@@ -306,7 +307,12 @@ private function checkRequirements(): void
306307
* Check if user does not have defined blowfish secret and it is being used.
307308
*/
308309
if (! empty($_SESSION['encryption_key'])) {
309-
$encryptionKeyLength = mb_strlen($GLOBALS['cfg']['blowfish_secret'], '8bit');
310+
$encryptionKeyLength = 0;
311+
// This can happen if the user did use getenv() to set blowfish_secret
312+
if (is_string($GLOBALS['cfg']['blowfish_secret'])) {
313+
$encryptionKeyLength = mb_strlen($GLOBALS['cfg']['blowfish_secret'], '8bit');
314+
}
315+
310316
if ($encryptionKeyLength < SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
311317
$this->errors[] = [
312318
'message' => __(

libraries/classes/DatabaseInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,11 +601,12 @@ static function ($a, $b) {
601601
*/
602602
public function getVirtualTables(string $db): array
603603
{
604-
$tablesFull = array_keys($this->getTablesFull($db));
604+
/** @var string[] $tablesFull */
605+
$tablesFull = array_column($this->getTablesFull($db), 'TABLE_NAME');
605606
$views = [];
606607

607608
foreach ($tablesFull as $table) {
608-
$table = $this->getTable($db, (string) $table);
609+
$table = $this->getTable($db, $table);
609610
if (! $table->isView()) {
610611
continue;
611612
}

libraries/classes/Git.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ class Git
5353
*/
5454
private bool $showGitRevision;
5555

56+
/**
57+
* The path where the to search for .git folders
58+
*/
59+
private string $baseDir;
60+
5661
/**
5762
* Git has been found and the data fetched
5863
*/
5964
private bool $hasGit = false;
6065

61-
public function __construct(bool $showGitRevision)
66+
public function __construct(bool $showGitRevision, string|null $baseDir = null)
6267
{
6368
$this->showGitRevision = $showGitRevision;
69+
$this->baseDir = $baseDir ?? ROOT_PATH;
6470
}
6571

6672
public function hasGitInformation(): bool
@@ -89,7 +95,7 @@ public function isGitRevision(&$git_location = null): bool
8995

9096
// find out if there is a .git folder
9197
// or a .git file (--separate-git-dir)
92-
$git = '.git';
98+
$git = $this->baseDir . '.git';
9399
if (is_dir($git)) {
94100
if (! @is_file($git . '/config')) {
95101
$_SESSION['git_location'] = null;

libraries/classes/Util.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ public static function getTableList($db): array
286286

287287
$tableGroups = [];
288288

289-
foreach ($tables as $tableName => $table) {
289+
foreach ($tables as $table) {
290+
/** @var string $tableName */
291+
$tableName = $table['TABLE_NAME'];
290292
$table['Rows'] = self::checkRowCount($db, $table);
291293

292294
// in $group we save the reference to the place in $table_groups
@@ -2224,10 +2226,7 @@ public static function getTablesWhenOpen($db, ResultInterface $dbInfoResult): ar
22242226
}
22252227

22262228
if (count($names) > 0) {
2227-
$tables = array_merge(
2228-
$tables,
2229-
$GLOBALS['dbi']->getTablesFull($db, $names),
2230-
);
2229+
$tables += $GLOBALS['dbi']->getTablesFull($db, $names);
22312230
}
22322231

22332232
if ($GLOBALS['cfg']['NaturalOrder']) {

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10745,11 +10745,6 @@ parameters:
1074510745
count: 1
1074610746
path: test/classes/Gis/GisPolygonTest.php
1074710747

10748-
-
10749-
message: "#^Casting to string something that's already string\\.$#"
10750-
count: 2
10751-
path: test/classes/GitTest.php
10752-
1075310748
-
1075410749
message: "#^Casting to string something that's already string\\.$#"
1075510750
count: 1

psalm-baseline.xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,9 @@
26322632
<PossiblyUnusedMethod>
26332633
<code>__construct</code>
26342634
</PossiblyUnusedMethod>
2635+
<RedundantCondition>
2636+
<code><![CDATA[is_string($GLOBALS['cfg']['blowfish_secret'])]]></code>
2637+
</RedundantCondition>
26352638
<UnusedVariable>
26362639
<code>$collationsList</code>
26372640
</UnusedVariable>
@@ -15190,8 +15193,6 @@
1519015193
</MixedArgument>
1519115194
<MixedArgumentTypeCoercion>
1519215195
<code>$columnNames</code>
15193-
<code>$tableName</code>
15194-
<code>$tableName</code>
1519515196
<code><![CDATA[uksort($tables, 'strnatcasecmp')]]></code>
1519615197
<code><![CDATA[uksort($tables, 'strnatcasecmp')]]></code>
1519715198
</MixedArgumentTypeCoercion>
@@ -15220,6 +15221,7 @@
1522015221
<code><![CDATA[$row['Seq_in_index']]]></code>
1522115222
<code><![CDATA[$row['Sub_part']]]></code>
1522215223
<code><![CDATA[$table['Name']]]></code>
15224+
<code><![CDATA[$table['TABLE_NAME']]]></code>
1522315225
</MixedArrayAccess>
1522415226
<MixedArrayAssignment>
1522515227
<code><![CDATA[$_SESSION['tmpval']['table_limit_offset']]]></code>
@@ -16629,12 +16631,6 @@
1662916631
<code>$queryString</code>
1663016632
</MixedAssignment>
1663116633
</file>
16632-
<file src="test/classes/GitTest.php">
16633-
<RedundantCast>
16634-
<code><![CDATA[(string) $this->cwd]]></code>
16635-
<code><![CDATA[(string) $this->testDir]]></code>
16636-
</RedundantCast>
16637-
</file>
1663816634
<file src="test/classes/HeaderTest.php">
1663916635
<MixedInferredReturnType>
1664016636
<code>array</code>

0 commit comments

Comments
 (0)