Update sql-parser dependency
Adds a quick fix for the sql-parser update. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
5140bedff1
commit
6aa4bc2e50
8
composer.lock
generated
8
composer.lock
generated
@ -454,12 +454,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpmyadmin/sql-parser.git",
|
||||
"reference": "0e24506244a1f4dde047af1eb71a32c8cb5a6e75"
|
||||
"reference": "c4efadf4562ad049a7244b90664c03cd568c3ebc"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/0e24506244a1f4dde047af1eb71a32c8cb5a6e75",
|
||||
"reference": "0e24506244a1f4dde047af1eb71a32c8cb5a6e75",
|
||||
"url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/c4efadf4562ad049a7244b90664c03cd568c3ebc",
|
||||
"reference": "c4efadf4562ad049a7244b90664c03cd568c3ebc",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -538,7 +538,7 @@
|
||||
"type": "other"
|
||||
}
|
||||
],
|
||||
"time": "2024-02-01T15:02:04+00:00"
|
||||
"time": "2024-02-05T17:02:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpmyadmin/twig-i18n-extension",
|
||||
|
||||
@ -10205,51 +10205,6 @@ parameters:
|
||||
count: 2
|
||||
path: src/Operations.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 0 on mixed\\.$#"
|
||||
count: 3
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 1 on mixed\\.$#"
|
||||
count: 1
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 2
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Offset 'select_tables' does not exist on array\\{distinct\\?\\: bool, drop_database\\?\\: bool, group\\?\\: bool, having\\?\\: bool, is_affected\\?\\: bool, is_analyse\\?\\: bool, is_count\\?\\: bool, is_delete\\?\\: bool, \\.\\.\\.\\}\\.$#"
|
||||
count: 1
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Offset 'select_tables' on array\\{distinct\\?\\: bool, drop_database\\?\\: bool, group\\?\\: bool, having\\?\\: bool, is_affected\\?\\: bool, is_analyse\\?\\: bool, is_count\\?\\: bool, is_delete\\?\\: bool, \\.\\.\\.\\} in empty\\(\\) does not exist\\.$#"
|
||||
count: 1
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Offset 'select_tables' on array\\{distinct\\?\\: bool, drop_database\\?\\: bool, group\\?\\: bool, having\\?\\: bool, is_affected\\?\\: bool, is_analyse\\?\\: bool, is_count\\?\\: bool, is_delete\\?\\: bool, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#"
|
||||
count: 1
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Offset 'select_tables' on array\\{distinct\\?\\: bool, drop_database\\?\\: bool, group\\?\\: bool, having\\?\\: bool, is_affected\\?\\: bool, is_analyse\\?\\: bool, is_count\\?\\: bool, is_delete\\?\\: bool, \\.\\.\\.\\} on left side of \\?\\? does not exist\\.$#"
|
||||
count: 1
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$info of static method PhpMyAdmin\\\\StatementInfo\\:\\:fromArray\\(\\) expects array\\{distinct\\: bool, drop_database\\: bool, group\\: bool, having\\: bool, is_affected\\: bool, is_analyse\\: bool, is_count\\: bool, is_delete\\: bool, \\.\\.\\.\\}, array\\{distinct\\?\\: bool, drop_database\\?\\: bool, group\\?\\: bool, having\\?\\: bool, is_affected\\?\\: bool, is_analyse\\?\\: bool, is_count\\?\\: bool, is_delete\\?\\: bool, \\.\\.\\.\\} given\\.$#"
|
||||
count: 1
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/ParseAnalyze.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 'Table' on mixed\\.$#"
|
||||
count: 4
|
||||
@ -14415,11 +14370,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Sql.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$info of static method PhpMyAdmin\\\\StatementInfo\\:\\:fromArray\\(\\) expects array\\{distinct\\: bool, drop_database\\: bool, group\\: bool, having\\: bool, is_affected\\: bool, is_analyse\\: bool, is_count\\: bool, is_delete\\: bool, \\.\\.\\.\\}, array\\{distinct\\?\\: bool, drop_database\\?\\: bool, group\\?\\: bool, having\\?\\: bool, is_affected\\?\\: bool, is_analyse\\?\\: bool, is_count\\?\\: bool, is_delete\\?\\: bool, \\.\\.\\.\\} given\\.$#"
|
||||
count: 1
|
||||
path: src/Sql.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$rows of static method PhpMyAdmin\\\\Message\\:\\:getMessageForAffectedRows\\(\\) expects int, int\\|string given\\.$#"
|
||||
count: 2
|
||||
@ -16465,11 +16415,6 @@ parameters:
|
||||
count: 2
|
||||
path: tests/classes/Display/ResultsTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$info of static method PhpMyAdmin\\\\StatementInfo\\:\\:fromArray\\(\\) expects array\\{distinct\\: bool, drop_database\\: bool, group\\: bool, having\\: bool, is_affected\\: bool, is_analyse\\: bool, is_count\\: bool, is_delete\\: bool, \\.\\.\\.\\}, array\\{distinct\\?\\: bool, drop_database\\?\\: bool, group\\?\\: bool, having\\?\\: bool, is_affected\\?\\: bool, is_analyse\\?\\: bool, is_count\\?\\: bool, is_delete\\?\\: bool, \\.\\.\\.\\} given\\.$#"
|
||||
count: 3
|
||||
path: tests/classes/Display/ResultsTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$string of function htmlspecialchars_decode expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -7850,14 +7850,6 @@
|
||||
<code><![CDATA['data']]></code>
|
||||
</TypeDoesNotContainNull>
|
||||
</file>
|
||||
<file src="src/ParseAnalyze.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code>$info</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[empty($info['select_tables'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Partitioning/Maintenance.php">
|
||||
<MixedArrayAccess>
|
||||
<code><![CDATA[$row['Table']]]></code>
|
||||
@ -11504,9 +11496,6 @@
|
||||
</MixedAssignment>
|
||||
</file>
|
||||
<file src="src/Sql.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code>Query::getAll($fullSqlQuery)</code>
|
||||
</ArgumentTypeCoercion>
|
||||
<DeprecatedMethod>
|
||||
<code>Config::getInstance()</code>
|
||||
<code>Config::getInstance()</code>
|
||||
@ -14165,11 +14154,6 @@
|
||||
</PossiblyUnusedMethod>
|
||||
</file>
|
||||
<file src="tests/classes/Display/ResultsTest.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code>Query::getAll($query)</code>
|
||||
<code>Query::getAll($query)</code>
|
||||
<code><![CDATA[Query::getAll('SELECT * FROM pma')]]></code>
|
||||
</ArgumentTypeCoercion>
|
||||
<DeprecatedMethod>
|
||||
<code>Config::getInstance()</code>
|
||||
<code>Config::getInstance()</code>
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Parse and analyse a SQL query
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
@ -13,7 +10,7 @@ use function count;
|
||||
use function strcasecmp;
|
||||
|
||||
/**
|
||||
* PhpMyAdmin\ParseAnalyze class
|
||||
* Parse and analyse a SQL query
|
||||
*/
|
||||
class ParseAnalyze
|
||||
{
|
||||
@ -38,12 +35,11 @@ class ParseAnalyze
|
||||
// If the targeted table (and database) are different than the ones that is
|
||||
// currently browsed, edit `$db` and `$table` to match them so other elements
|
||||
// (page headers, links, navigation panel) can be updated properly.
|
||||
if (! empty($info['select_tables'])) {
|
||||
if ($info->selectTables !== []) {
|
||||
// Previous table and database name is stored to check if it changed.
|
||||
$previousDb = $db;
|
||||
|
||||
if (count($info['select_tables']) > 1) {
|
||||
|
||||
if (count($info->selectTables) > 1) {
|
||||
/**
|
||||
* @todo if there are more than one table name in the Select:
|
||||
* - do not extract the first table name
|
||||
@ -52,21 +48,21 @@ class ParseAnalyze
|
||||
*/
|
||||
$table = '';
|
||||
} else {
|
||||
$table = $info['select_tables'][0][0] ?? '';
|
||||
if (isset($info['select_tables'][0][1])) {
|
||||
$db = $info['select_tables'][0][1];
|
||||
$table = $info->selectTables[0][0] ?? '';
|
||||
if (isset($info->selectTables[0][1])) {
|
||||
$db = $info->selectTables[0][1];
|
||||
}
|
||||
}
|
||||
|
||||
// There is no point checking if a reloading is required if we already decided
|
||||
// to reload. Also, no reload is required for AJAX requests.
|
||||
$response = ResponseRenderer::getInstance();
|
||||
if (empty($info['reload']) && ! $response->isAjax()) {
|
||||
if (! $info->flags->reload && ! $response->isAjax()) {
|
||||
// NOTE: Database names are case-insensitive.
|
||||
$info['reload'] = strcasecmp($db, $previousDb) !== 0;
|
||||
$info->flags->reload = strcasecmp($db, $previousDb) !== 0;
|
||||
}
|
||||
}
|
||||
|
||||
return [StatementInfo::fromArray($info), $db, $table];
|
||||
return [StatementInfo::fromStatementInfo($info), $db, $table];
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ class Sql
|
||||
);
|
||||
|
||||
// TODO: Avoid reparsing the query.
|
||||
$statementInfo = StatementInfo::fromArray(Query::getAll($fullSqlQuery));
|
||||
$statementInfo = StatementInfo::fromStatementInfo(Query::getAll($fullSqlQuery));
|
||||
} else {
|
||||
// Store the remembered table into session.
|
||||
$tableObject->setUiProp(
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\SqlParser\Parser;
|
||||
use PhpMyAdmin\SqlParser\Statement;
|
||||
use PhpMyAdmin\SqlParser\Utils\StatementInfo as SqlParserStatementInfo;
|
||||
|
||||
/** @psalm-immutable */
|
||||
class StatementInfo
|
||||
@ -126,4 +127,42 @@ class StatementInfo
|
||||
$info['select_expr'] ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
public static function fromStatementInfo(SqlParserStatementInfo $statementInfo): self
|
||||
{
|
||||
/** @psalm-suppress DeprecatedProperty */
|
||||
return new self(
|
||||
$statementInfo->flags->distinct,
|
||||
$statementInfo->flags->dropDatabase,
|
||||
$statementInfo->flags->group,
|
||||
$statementInfo->flags->having,
|
||||
$statementInfo->flags->isAffected,
|
||||
$statementInfo->flags->isAnalyse,
|
||||
$statementInfo->flags->isCount,
|
||||
$statementInfo->flags->isDelete,
|
||||
$statementInfo->flags->isExplain,
|
||||
$statementInfo->flags->isExport,
|
||||
$statementInfo->flags->isFunc,
|
||||
$statementInfo->flags->isGroup,
|
||||
$statementInfo->flags->isInsert,
|
||||
$statementInfo->flags->isMaint,
|
||||
$statementInfo->flags->isProcedure,
|
||||
$statementInfo->flags->isReplace,
|
||||
$statementInfo->flags->isSelect,
|
||||
$statementInfo->flags->isShow,
|
||||
$statementInfo->flags->isSubQuery,
|
||||
$statementInfo->flags->join,
|
||||
$statementInfo->flags->limit,
|
||||
$statementInfo->flags->offset,
|
||||
$statementInfo->flags->order,
|
||||
$statementInfo->flags->queryType?->value ?? false,
|
||||
$statementInfo->flags->reload,
|
||||
$statementInfo->flags->selectFrom,
|
||||
$statementInfo->flags->union,
|
||||
$statementInfo->parser,
|
||||
$statementInfo->statement,
|
||||
$statementInfo->selectTables,
|
||||
$statementInfo->selectExpressions,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ class ResultsTest extends AbstractTestCase
|
||||
$this->object,
|
||||
DisplayResults::class,
|
||||
'isSelect',
|
||||
[StatementInfo::fromArray(Query::getAll('SELECT * FROM pma'))],
|
||||
[StatementInfo::fromStatementInfo(Query::getAll('SELECT * FROM pma'))],
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -321,7 +321,7 @@ class ResultsTest extends AbstractTestCase
|
||||
$this->object,
|
||||
DisplayResults::class,
|
||||
'setHighlightedColumnGlobalField',
|
||||
[StatementInfo::fromArray(Query::getAll($query))],
|
||||
[StatementInfo::fromStatementInfo(Query::getAll($query))],
|
||||
);
|
||||
|
||||
self::assertEquals([
|
||||
@ -712,7 +712,7 @@ class ResultsTest extends AbstractTestCase
|
||||
'disabled',
|
||||
false,
|
||||
$query,
|
||||
StatementInfo::fromArray(Query::getAll($query)),
|
||||
StatementInfo::fromStatementInfo(Query::getAll($query)),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user