Merge pull request #19484 from kamil-tekiela/Remove-unnecessary-nullability

Remove unnecessary nullability
This commit is contained in:
Maurício Meneghini Fauth 2025-01-02 16:21:32 -03:00 committed by GitHub
commit bde143d76e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 154 additions and 198 deletions

View File

@ -3898,13 +3898,7 @@ parameters:
path: src/Controllers/Sql/SqlController.php
-
message: '#^Parameter \#10 \$dispMessage of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects PhpMyAdmin\\Message\|string\|null, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Sql/SqlController.php
-
message: '#^Parameter \#12 \$completeQuery of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string\|null, mixed given\.$#'
message: '#^Parameter \#11 \$completeQuery of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Sql/SqlController.php
@ -3916,19 +3910,25 @@ parameters:
path: src/Controllers/Sql/SqlController.php
-
message: '#^Parameter \#5 \$sqlQueryForBookmark of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string\|null, mixed given\.$#'
message: '#^Parameter \#5 \$sqlQueryForBookmark of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Sql/SqlController.php
-
message: '#^Parameter \#6 \$messageToShow of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string\|null, mixed given\.$#'
message: '#^Parameter \#6 \$messageToShow of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Sql/SqlController.php
-
message: '#^Parameter \#9 \$dispQuery of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string\|null, mixed given\.$#'
message: '#^Parameter \#8 \$dispQuery of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string\|null, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Sql/SqlController.php
-
message: '#^Parameter \#9 \$dispMessage of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects PhpMyAdmin\\Message\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Sql/SqlController.php
@ -4185,12 +4185,6 @@ parameters:
count: 1
path: src/Controllers/Table/DeleteRowsController.php
-
message: '#^Parameter \#10 \$dispMessage of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects PhpMyAdmin\\Message\|string\|null, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Table/DeleteRowsController.php
-
message: '#^Parameter \#3 \$pos of method PhpMyAdmin\\Sql\:\:calculatePosForLastPage\(\) expects int\|null, mixed given\.$#'
identifier: argument.type
@ -4204,7 +4198,13 @@ parameters:
path: src/Controllers/Table/DeleteRowsController.php
-
message: '#^Parameter \#9 \$dispQuery of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string\|null, mixed given\.$#'
message: '#^Parameter \#8 \$dispQuery of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects string\|null, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Table/DeleteRowsController.php
-
message: '#^Parameter \#9 \$dispMessage of method PhpMyAdmin\\Sql\:\:executeQueryAndSendQueryResponse\(\) expects PhpMyAdmin\\Message\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Table/DeleteRowsController.php
@ -15915,19 +15915,13 @@ parameters:
-
message: '#^Only booleans are allowed in &&, string given on the right side\.$#'
identifier: booleanAnd.rightNotBoolean
count: 2
path: src/Sql.php
-
message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#'
identifier: booleanAnd.leftNotBoolean
count: 1
count: 3
path: src/Sql.php
-
message: '#^Only booleans are allowed in &&, string\|null given on the right side\.$#'
identifier: booleanAnd.rightNotBoolean
count: 2
count: 1
path: src/Sql.php
-
@ -15991,13 +15985,7 @@ parameters:
path: src/Sql.php
-
message: '#^Parameter \#2 \$table of method PhpMyAdmin\\Sql\:\:handleSortOrder\(\) expects string, string\|null given\.$#'
identifier: argument.type
count: 1
path: src/Sql.php
-
message: '#^Parameter \#3 \$column of method PhpMyAdmin\\Sql\:\:cleanupRelations\(\) expects string\|null, mixed given\.$#'
message: '#^Parameter \#3 \$column of method PhpMyAdmin\\Sql\:\:cleanupRelations\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Sql.php
@ -16009,7 +15997,7 @@ parameters:
path: src/Sql.php
-
message: '#^Parameter \#5 \$bookmarkLabel of method PhpMyAdmin\\Sql\:\:storeTheQueryAsBookmark\(\) expects string, mixed given\.$#'
message: '#^Parameter \#4 \$bookmarkLabel of method PhpMyAdmin\\Sql\:\:storeTheQueryAsBookmark\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Sql.php

View File

@ -2373,8 +2373,8 @@
<code><![CDATA[$GLOBALS['unlim_num_rows']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$GLOBALS['disp_message'] ?? null]]></code>
<code><![CDATA[$GLOBALS['message_to_show'] ?? null]]></code>
<code><![CDATA[$GLOBALS['disp_message'] ?? '']]></code>
<code><![CDATA[$GLOBALS['message_to_show'] ?? '']]></code>
<code><![CDATA[$request->getQueryParam('sql_signature')]]></code>
</MixedArgument>
<MixedArrayAccess>
@ -2568,7 +2568,7 @@
<code><![CDATA[$GLOBALS['disp_query']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$GLOBALS['disp_message'] ?? null]]></code>
<code><![CDATA[$GLOBALS['disp_message'] ?? '']]></code>
<code><![CDATA[$GLOBALS['disp_query'] ?? null]]></code>
<code><![CDATA[$row]]></code>
</MixedArgument>
@ -9341,7 +9341,7 @@
</NullableReturnStatement>
<PossiblyInvalidArgument>
<code><![CDATA[$_POST['bkm_label']]]></code>
<code><![CDATA[$_POST['dropped_column'] ?? null]]></code>
<code><![CDATA[$_POST['dropped_column'] ?? '']]></code>
<code><![CDATA[$numRows]]></code>
<code><![CDATA[$numRows]]></code>
<code><![CDATA[$numRows]]></code>
@ -9349,6 +9349,7 @@
</PossiblyInvalidArgument>
<PossiblyInvalidCast>
<code><![CDATA[$_POST['bkm_label']]]></code>
<code><![CDATA[$_POST['dropped_column'] ?? '']]></code>
</PossiblyInvalidCast>
<PossiblyInvalidOperand>
<code><![CDATA[$numRows]]></code>
@ -9362,7 +9363,6 @@
<code><![CDATA[$statementInfo->parser->list]]></code>
<code><![CDATA[$statementInfo->parser->list]]></code>
<code><![CDATA[$statementInfo->parser->list]]></code>
<code><![CDATA[$table]]></code>
</PossiblyNullArgument>
<PossiblyNullReference>
<code><![CDATA[has]]></code>
@ -9375,8 +9375,6 @@
</RedundantCondition>
<RiskyTruthyFalsyComparison>
<code><![CDATA[! $index->isUnique()]]></code>
<code><![CDATA[$messageToShow]]></code>
<code><![CDATA[$sqlQueryForBookmark]]></code>
<code><![CDATA[$table]]></code>
<code><![CDATA[empty($_GET['id_bookmark'])]]></code>
<code><![CDATA[empty($_GET['id_bookmark'])]]></code>

View File

@ -84,9 +84,9 @@ class Form
*
* @param string $optionName path or field name
*
* @return string|null one of: boolean, integer, double, string, select, array
* @return string one of: boolean, integer, double, string, select, array
*/
public function getOptionType(string $optionName): string|null
public function getOptionType(string $optionName): string
{
$key = ltrim(
mb_substr(
@ -96,7 +96,7 @@ class Form
'/',
);
return $this->fieldsTypes[$key] ?? null;
return $this->fieldsTypes[$key] ?? '';
}
/**

View File

@ -204,17 +204,17 @@ class FormDisplay
/**
* Outputs HTML for forms
*
* @param bool $showButtons whether show submit and reset button
* @param string|null $formAction action attribute for the form
* @param mixed[]|null $hiddenFields array of form hidden fields (key: field
* @param bool $showButtons whether show submit and reset button
* @param string $formAction action attribute for the form
* @param mixed[] $hiddenFields array of form hidden fields (key: field
* name)
*
* @return string HTML for forms
*/
public function getDisplay(
bool $showButtons = true,
string|null $formAction = null,
array|null $hiddenFields = null,
string $formAction = '',
array $hiddenFields = [],
): string {
$fieldValidators = [];
$defaultValues = [];
@ -293,7 +293,7 @@ class FormDisplay
return $this->formDisplayTemplate->display([
'action' => $formAction,
'has_check_page_refresh' => self::$hasCheckPageRefresh,
'hidden_fields' => (array) $hiddenFields,
'hidden_fields' => $hiddenFields,
'tabs' => $tabs,
'forms' => $forms,
'show_buttons' => $showButtons,
@ -566,7 +566,7 @@ class FormDisplay
foreach ($form->fields as $field => $systemPath) {
$workPath = array_search($systemPath, $this->systemPaths);
$key = $this->translatedPaths[$workPath];
$type = (string) $form->getOptionType($field);
$type = $form->getOptionType($field);
// skip groups
if ($type === 'group') {

View File

@ -1235,10 +1235,10 @@ class Relation
/**
* Create a PDF page
*
* @param string|null $newpage name of the new PDF page
* @param string $db database name
* @param string $newpage name of the new PDF page
* @param string $db database name
*/
public function createPage(string|null $newpage, PdfFeature $pdfFeature, string $db): int
public function createPage(string $newpage, PdfFeature $pdfFeature, string $db): int
{
$insQuery = 'INSERT INTO '
. Util::backquote($pdfFeature->database) . '.'
@ -1247,7 +1247,7 @@ class Relation
. ' VALUES ('
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString(
$newpage !== null && $newpage !== '' ? $newpage : __('no description'),
$newpage !== '' ? $newpage : __('no description'),
ConnectionType::ControlUser,
) . ')';
$this->dbi->tryQueryAsControlUser($insQuery);

View File

@ -42,7 +42,7 @@ final class CentralColumnsController implements InvocableController
$request->getParsedBodyParamAsString('orig_col_name'),
$request->getParsedBodyParamAsString('col_default'),
$request->getParsedBodyParamAsString('col_default_sel'),
$request->getParsedBodyParamAsStringOrNull('col_extra'),
$request->getParsedBodyParamAsString('col_extra', ''),
$request->getParsedBodyParamAsStringOrNull('col_isNull'),
$request->getParsedBodyParamAsString('col_length'),
$request->getParsedBodyParamAsString('col_attribute'),
@ -60,7 +60,7 @@ final class CentralColumnsController implements InvocableController
$request->getParsedBodyParamAsString('col_name'),
$request->getParsedBodyParamAsString('col_default'),
$request->getParsedBodyParamAsString('col_default_sel'),
$request->getParsedBodyParamAsStringOrNull('col_extra'),
$request->getParsedBodyParamAsString('col_extra', ''),
$request->getParsedBodyParamAsStringOrNull('col_isNull'),
$request->getParsedBodyParamAsString('col_length'),
$request->getParsedBodyParamAsString('col_attribute'),
@ -176,7 +176,7 @@ final class CentralColumnsController implements InvocableController
string $origColName,
string $colDefault,
string $colDefaultSel,
string|null $colExtra,
string $colExtra,
string|null $colIsNull,
string $colLength,
string $colAttribute,
@ -198,7 +198,7 @@ final class CentralColumnsController implements InvocableController
$colLength,
$colIsNull !== null,
$collation,
$colExtra ?? '',
$colExtra,
$columnDefault,
);
}
@ -207,7 +207,7 @@ final class CentralColumnsController implements InvocableController
string $colName,
string $colDefault,
string $colDefaultSel,
string|null $colExtra,
string $colExtra,
string|null $colIsNull,
string $colLength,
string $colAttribute,
@ -224,7 +224,7 @@ final class CentralColumnsController implements InvocableController
$colLength,
$colIsNull !== null,
$collation,
$colExtra ?? '',
$colExtra,
$colDefault === 'NONE' && $colDefaultSel !== 'USER_DEFINED' ? '' : $colDefault,
);
}

View File

@ -649,14 +649,13 @@ final class ImportController implements InvocableController
false, // is_gotofile
Current::$database, // db
Current::$table, // table
null, // sql_query_for_bookmark - see below
null, // message_to_show
null, // sql_data
'', // sql_query_for_bookmark - see below
'', // message_to_show
UrlParams::$goto, // goto
null, // disp_query
null, // disp_message
'', // disp_message
Current::$sqlQuery,
null, // complete_query
Current::$sqlQuery, // complete_query
);
}
@ -664,10 +663,7 @@ final class ImportController implements InvocableController
// since only one bookmark has to be added for all the queries submitted through
// the SQL tab
if (! empty($request->getParsedBodyParam('bkm_label')) && ! empty($GLOBALS['import_text'])) {
$relation = new Relation($this->dbi);
$this->sql->storeTheQueryAsBookmark(
$relation->getRelationParameters()->bookmarkFeature,
Current::$database,
$config->selectedServer['user'],
$request->getParsedBodyParamAsString('sql_query'),
@ -695,7 +691,6 @@ final class ImportController implements InvocableController
$relation = new Relation($this->dbi);
$this->sql->storeTheQueryAsBookmark(
$relation->getRelationParameters()->bookmarkFeature,
Current::$database,
$config->selectedServer['user'],
$request->getParsedBodyParamAsString('sql_query'),

View File

@ -191,14 +191,13 @@ class SqlController implements InvocableController
$isGotofile,
Current::$database,
Current::$table,
$GLOBALS['import_text'] ?? null,
$GLOBALS['message_to_show'] ?? null,
null,
$GLOBALS['import_text'] ?? '',
$GLOBALS['message_to_show'] ?? '',
UrlParams::$goto,
isset($GLOBALS['disp_query']) ? $GLOBALS['display_query'] : null,
$GLOBALS['disp_message'] ?? null,
$GLOBALS['disp_message'] ?? '',
Current::$sqlQuery,
$GLOBALS['complete_query'] ?? null,
$GLOBALS['complete_query'] ?? Current::$sqlQuery,
));
return $this->response->response();

View File

@ -87,14 +87,13 @@ final class DeleteRowsController implements InvocableController
false,
Current::$database,
Current::$table,
null,
null,
null,
'',
'',
UrlParams::$goto,
$GLOBALS['disp_query'] ?? null,
$GLOBALS['disp_message'] ?? null,
$GLOBALS['disp_message'] ?? '',
Current::$sqlQuery,
Current::$sqlQuery,
null,
));
return $this->response->response();

View File

@ -250,14 +250,13 @@ final class SearchController implements InvocableController
false, // is_gotofile
Current::$database, // db
Current::$table, // table
null, // sql_query_for_bookmark
null, // message_to_show
null, // sql_data
'', // sql_query_for_bookmark
'', // message_to_show
UrlParams::$goto, // goto
null, // disp_query
null, // disp_message
'', // disp_message
$sqlQuery, // sql_query
null, // complete_query
$sqlQuery, // complete_query
));
}

View File

@ -66,14 +66,13 @@ final class BrowseController implements InvocableController
false, // is_gotofile
Current::$database, // db
Current::$table, // table
null, // sql_query_for_bookmark
null, // message_to_show
null, // sql_data
'', // sql_query_for_bookmark
'', // message_to_show
$goto, // goto
null, // disp_query
null, // disp_message
'', // disp_message
$sqlQuery, // sql_query
null, // complete_query
$sqlQuery, // complete_query
),
);
}

View File

@ -91,14 +91,13 @@ class MultiTableQuery
false, // is_gotofile
$db, // db
null, // table
null, // sql_query_for_bookmark - see below
null, // message_to_show
null, // sql_data
'', // sql_query_for_bookmark - see below
'', // message_to_show
$goto, // goto
null, // disp_query
null, // disp_message
'', // disp_message
$sqlQuery, // sql_query
null, // complete_query
$sqlQuery, // complete_query
);
}
}

View File

@ -5,7 +5,6 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Bookmarks\BookmarkRepository;
use PhpMyAdmin\ConfigStorage\Features\BookmarkFeature;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\ConfigStorage\RelationCleanup;
use PhpMyAdmin\Dbal\DatabaseInterface;
@ -508,15 +507,13 @@ class Sql
* @param bool $bookmarkReplace whether to replace existing bookmarks
*/
public function storeTheQueryAsBookmark(
BookmarkFeature|null $bookmarkFeature,
string $db,
string $bookmarkUser,
string $sqlQueryForBookmark,
string $bookmarkLabel,
bool $bookmarkReplace,
): void {
// Should we replace bookmark?
if ($bookmarkReplace && $bookmarkFeature !== null) {
if ($bookmarkReplace) {
$bookmarks = $this->bookmarkRepository->getList($this->config->selectedServer['user'], $db);
foreach ($bookmarks as $bookmark) {
if ($bookmark->getLabel() !== $bookmarkLabel) {
@ -587,19 +584,19 @@ class Sql
/**
* If a table, database or column gets dropped, clean comments.
*
* @param string $db current database
* @param string $table current table
* @param string|null $column current column
* @param bool $purge whether purge set or not
* @param string $db current database
* @param string $table current table
* @param string $column current column
* @param bool $purge whether purge set or not
*/
private function cleanupRelations(string $db, string $table, string|null $column, bool $purge): void
private function cleanupRelations(string $db, string $table, string $column, bool $purge): void
{
if (! $purge || $db === '') {
return;
}
if ($table !== '') {
if ($column !== null && $column !== '') {
if ($column !== '') {
$this->relationCleanup->column($db, $table, $column);
} else {
$this->relationCleanup->table($db, $table);
@ -706,11 +703,11 @@ class Sql
/**
* Function to handle all aspects relating to executing the query
*
* @param string $fullSqlQuery full sql query
* @param bool $isGotoFile whether to go to a file
* @param string $db current database
* @param string|null $table current table
* @param string|null $sqlQueryForBookmark sql query to be stored as bookmark
* @param string $fullSqlQuery full sql query
* @param bool $isGotoFile whether to go to a file
* @param string $db current database
* @param string $table current table
* @param string $sqlQueryForBookmark sql query to be stored as bookmark
*
* @psalm-return array{
* ResultInterface|false,
@ -725,11 +722,11 @@ class Sql
string $fullSqlQuery,
bool $isGotoFile,
string $db,
string|null $table,
string|null $sqlQueryForBookmark,
string $table,
string $sqlQueryForBookmark,
): array {
$response = ResponseRenderer::getInstance();
$response->getHeader()->getMenu()->setTable($table ?? '');
$response->getHeader()->getMenu()->setTable($table);
Profiling::enable($this->dbi);
@ -759,11 +756,9 @@ class Sql
// If there are no errors and bookmarklabel was given,
// store the query as a bookmark
if (! empty($_POST['bkm_label']) && $sqlQueryForBookmark) {
$bookmarkFeature = $this->relation->getRelationParameters()->bookmarkFeature;
$this->storeTheQueryAsBookmark(
$bookmarkFeature,
$db,
$bookmarkFeature !== null ? $this->config->selectedServer['user'] : '',
$this->config->selectedServer['user'],
$sqlQueryForBookmark,
$_POST['bkm_label'],
isset($_POST['bkm_replace']),
@ -779,9 +774,9 @@ class Sql
$justBrowsing = self::isJustBrowsing($statementInfo);
$unlimNumRows = $this->countQueryResults($numRows, $justBrowsing, $db, $table ?? '', $statementInfo);
$unlimNumRows = $this->countQueryResults($numRows, $justBrowsing, $db, $table, $statementInfo);
$this->cleanupRelations($db, $table ?? '', $_POST['dropped_column'] ?? null, ! empty($_POST['purge']));
$this->cleanupRelations($db, $table, $_POST['dropped_column'] ?? '', ! empty($_POST['purge']));
return [$result, $numRows, $unlimNumRows, $profilingResults, $errorMessage];
}
@ -815,11 +810,11 @@ class Sql
/**
* Function to get the message for the no rows returned case
*
* @param string|null $messageToShow message to show
* @param int|string $numRows number of rows
* @param string $messageToShow message to show
* @param int|string $numRows number of rows
*/
private function getMessageForNoRowsReturned(
string|null $messageToShow,
string $messageToShow,
StatementInfo $statementInfo,
int|string $numRows,
): Message {
@ -856,7 +851,7 @@ class Sql
// fact that $message_to_show is sent for every case.
// The $message_to_show containing a success message and sent with
// the form should not have priority over errors
} elseif ($messageToShow && $statementInfo->flags->queryType !== StatementType::Select) {
} elseif ($messageToShow !== '' && $statementInfo->flags->queryType !== StatementType::Select) {
$message = Message::rawSuccess(htmlspecialchars($messageToShow));
} elseif (! empty($GLOBALS['show_as_php'])) {
$message = Message::success(__('Showing as PHP code'));
@ -898,13 +893,13 @@ class Sql
*
* @param string $db current database
* @param string|null $table current table
* @param string|null $messageToShow message to show
* @param string $messageToShow message to show
* @param int|string $numRows number of rows
* @param DisplayResults $displayResultsObject DisplayResult instance
* @param string $errorMessage error message from tryQuery
* @param ResultInterface|false $result executed query results
* @param string $sqlQuery sql query
* @param string|null $completeQuery complete sql query
* @param string $completeQuery complete sql query
* @psalm-param int|numeric-string $numRows
* @psalm-param list<array{Status: non-empty-string, Duration: numeric-string}> $profilingResults
*
@ -914,14 +909,14 @@ class Sql
StatementInfo $statementInfo,
string $db,
string|null $table,
string|null $messageToShow,
string $messageToShow,
int|string $numRows,
DisplayResults $displayResultsObject,
string $errorMessage,
array $profilingResults,
ResultInterface|false $result,
string $sqlQuery,
string|null $completeQuery,
string $completeQuery,
): string {
if ($this->isDeleteTransformationInfo($statementInfo)) {
$this->deleteTransformationInfo($db, $table ?? '', $statementInfo);
@ -1011,7 +1006,7 @@ class Sql
'id_bookmark' => 1,
]),
'user' => $this->config->selectedServer['user'],
'sql_query' => $completeQuery ?? $sqlQuery,
'sql_query' => $completeQuery,
'allow_shared_bookmarks' => $this->config->settings['AllowSharedBookmarks'],
]);
}
@ -1182,16 +1177,14 @@ class Sql
*
* @param string|null $displayQuery display query
* @param bool $showSql whether to show sql
* @param mixed[] $sqlData sql data
* @param Message|string $displayMessage display message
*/
private function getHtmlForPreviousUpdateQuery(
string|null $displayQuery,
bool $showSql,
array $sqlData,
Message|string $displayMessage,
): string {
if ($displayQuery !== null && $showSql && $sqlData === []) {
if ($displayQuery !== null && $showSql) {
return Generator::getMessage($displayMessage, $displayQuery, MessageType::Success);
}
@ -1201,21 +1194,15 @@ class Sql
/**
* To get the message if a column index is missing. If not will return null
*
* @param string|null $table current table
* @param string $database current database
* @param bool $editable whether the results table can be editable or not
* @param bool $hasUniqueKey whether there is a unique key
* @param string $database current database
* @param bool $editable whether the results table can be editable or not
* @param bool $hasUniqueKey whether there is a unique key
*/
private function getMessageIfMissingColumnIndex(
string|null $table,
string $database,
bool $editable,
bool $hasUniqueKey,
): string {
if ($table === null) {
return '';
}
$output = '';
if (Utilities::isSystemSchema($database) || ! $editable) {
$output = Message::notice(
@ -1253,17 +1240,16 @@ class Sql
/**
* Function to display results when the executed query returns non empty results
*
* @param ResultInterface $result executed query results
* @param string $db current database
* @param string|null $table current table
* @param mixed[]|null $sqlData sql data
* @param DisplayResults $displayResultsObject Instance of DisplayResults
* @param int|string $unlimNumRows unlimited number of rows
* @param int|string $numRows number of rows
* @param string|null $dispQuery display query
* @param Message|string|null $dispMessage display message
* @param string $sqlQuery sql query
* @param string|null $completeQuery complete sql query
* @param ResultInterface $result executed query results
* @param string $db current database
* @param string|null $table current table
* @param DisplayResults $displayResultsObject Instance of DisplayResults
* @param int|string $unlimNumRows unlimited number of rows
* @param int|string $numRows number of rows
* @param string|null $dispQuery display query
* @param Message|string $dispMessage display message
* @param string $sqlQuery sql query
* @param string $completeQuery complete sql query
* @psalm-param int|numeric-string $unlimNumRows
* @psalm-param int|numeric-string $numRows
* @psalm-param list<array{Status: non-empty-string, Duration: numeric-string}> $profilingResults
@ -1275,15 +1261,14 @@ class Sql
StatementInfo $statementInfo,
string $db,
string|null $table,
array|null $sqlData,
DisplayResults $displayResultsObject,
int|string $unlimNumRows,
int|string $numRows,
string|null $dispQuery,
Message|string|null $dispMessage,
Message|string $dispMessage,
array $profilingResults,
string $sqlQuery,
string|null $completeQuery,
string $completeQuery,
): string {
// If we are retrieving the full value of a truncated field or the original
// value of a transformed field, show it here
@ -1381,13 +1366,14 @@ class Sql
$previousUpdateQueryHtml = $this->getHtmlForPreviousUpdateQuery(
$dispQuery,
$this->config->settings['ShowSQL'],
$sqlData ?? [],
$dispMessage ?? '',
$dispMessage,
);
$profilingChartHtml = $this->getProfilingChart($profilingResults);
$missingUniqueColumnMessage = $this->getMessageIfMissingColumnIndex($table, $db, $editable, $hasUnique);
$missingUniqueColumnMessage = $table !== null
? $this->getMessageIfMissingColumnIndex($db, $editable, $hasUnique)
: '';
$bookmarkCreatedMessage = $this->getBookmarkCreatedMessage();
@ -1418,7 +1404,7 @@ class Sql
'id_bookmark' => 1,
]),
'user' => $this->config->selectedServer['user'],
'sql_query' => $completeQuery ?? $sqlQuery,
'sql_query' => $completeQuery,
]);
}
@ -1435,31 +1421,29 @@ class Sql
/**
* Function to execute the query and send the response
*
* @param bool $isGotoFile whether goto file or not
* @param string $db current database
* @param string|null $table current table
* @param string|null $sqlQueryForBookmark the sql query to be stored as bookmark
* @param string|null $messageToShow message to show
* @param mixed[]|null $sqlData sql data
* @param string $goto goto page url
* @param string|null $dispQuery display query
* @param Message|string|null $dispMessage display message
* @param string $sqlQuery sql query
* @param string|null $completeQuery complete query
* @param bool $isGotoFile whether goto file or not
* @param string $db current database
* @param string|null $table current table
* @param string $sqlQueryForBookmark the sql query to be stored as bookmark
* @param string $messageToShow message to show
* @param string $goto goto page url
* @param string|null $dispQuery display query
* @param Message|string $dispMessage display message
* @param string $sqlQuery sql query
* @param string $completeQuery complete query
*/
public function executeQueryAndSendQueryResponse(
StatementInfo|null $statementInfo,
bool $isGotoFile,
string $db,
string|null $table,
string|null $sqlQueryForBookmark,
string|null $messageToShow,
array|null $sqlData,
string $sqlQueryForBookmark,
string $messageToShow,
string $goto,
string|null $dispQuery,
Message|string|null $dispMessage,
Message|string $dispMessage,
string $sqlQuery,
string|null $completeQuery,
string $completeQuery,
): string {
if ($statementInfo === null) {
// Parse and analyze the query
@ -1475,7 +1459,6 @@ class Sql
$table, // table
$sqlQueryForBookmark, // sql_query_for_bookmark
$messageToShow, // message_to_show
$sqlData, // sql_data
$goto, // goto
$dispQuery, // disp_query
$dispMessage, // disp_message
@ -1487,17 +1470,16 @@ class Sql
/**
* Function to execute the query and send the response
*
* @param bool $isGotoFile whether goto file or not
* @param string $db current database
* @param string|null $table current table
* @param string|null $sqlQueryForBookmark the sql query to be stored as bookmark
* @param string|null $messageToShow message to show
* @param mixed[]|null $sqlData sql data
* @param string $goto goto page url
* @param string|null $dispQuery display query
* @param Message|string|null $dispMessage display message
* @param string $sqlQuery sql query
* @param string|null $completeQuery complete query
* @param bool $isGotoFile whether goto file or not
* @param string $db current database
* @param string|null $table current table
* @param string $sqlQueryForBookmark the sql query to be stored as bookmark
* @param string $messageToShow message to show
* @param string $goto goto page url
* @param string|null $dispQuery display query
* @param Message|string $dispMessage display message
* @param string $sqlQuery sql query
* @param string $completeQuery complete query
*
* @return string html
*/
@ -1506,14 +1488,13 @@ class Sql
bool $isGotoFile,
string $db,
string|null $table,
string|null $sqlQueryForBookmark,
string|null $messageToShow,
array|null $sqlData,
string $sqlQueryForBookmark,
string $messageToShow,
string $goto,
string|null $dispQuery,
Message|string|null $dispMessage,
Message|string $dispMessage,
string $sqlQuery,
string|null $completeQuery,
string $completeQuery,
): string {
// Handle remembered sorting order, only for single table query.
// Handling is not required when it's a union query
@ -1526,7 +1507,7 @@ class Sql
&& ! isset($_POST['sort_by_key'])
) {
if (! isset($_SESSION['sql_from_query_box'])) {
$statementInfo = $this->handleSortOrder($db, $table, $statementInfo, $sqlQuery);
$statementInfo = $this->handleSortOrder($db, $table ?? '', $statementInfo, $sqlQuery);
} else {
unset($_SESSION['sql_from_query_box']);
}
@ -1575,7 +1556,7 @@ class Sql
$fullSqlQuery,
$isGotoFile,
$db,
$table,
$table ?? '',
$sqlQueryForBookmark,
);
@ -1603,7 +1584,6 @@ class Sql
$statementInfo,
$db,
$table,
$sqlData,
$displayResultsObject,
$unlimNumRows,
$numRows,

View File

@ -68,7 +68,8 @@ class FormTest extends AbstractTestCase
['7' => 'Seven'],
);
self::assertNull(
self::assertSame(
'',
$this->object->getOptionType('123/4/5/6'),
);

View File

@ -607,14 +607,13 @@ class SqlTest extends AbstractTestCase
false,
'sakila',
'different_table',
null,
null,
null,
'',
'',
'index.php?route=/sql',
null,
null,
'',
'SELECT * FROM `sakila`.`country` LIMIT 0, 3;',
'SELECT * FROM `sakila`.`country` LIMIT 0, 3;',
null,
);
self::assertStringContainsString('Showing rows 0 - 2 (3 total', $actual);
self::assertStringContainsString('SELECT * FROM `sakila`.`country` LIMIT 0, 3;', $actual);