Merge pull request #17873 from kamil-tekiela/Remove-$params-3
Refactor BinlogController.php
This commit is contained in:
commit
1c49ed0d18
@ -44,33 +44,27 @@ class BinlogController extends AbstractController
|
||||
|
||||
public function __invoke(ServerRequest $request): void
|
||||
{
|
||||
$GLOBALS['errorUrl'] = $GLOBALS['errorUrl'] ?? null;
|
||||
$log = $request->getParsedBodyParam('log');
|
||||
$position = (int) $request->getParsedBodyParam('pos', 0);
|
||||
|
||||
$params = [
|
||||
'log' => $_POST['log'] ?? null,
|
||||
'pos' => $_POST['pos'] ?? null,
|
||||
'is_full_query' => $_POST['is_full_query'] ?? null,
|
||||
];
|
||||
$GLOBALS['errorUrl'] = Url::getFromRoute('/');
|
||||
|
||||
if ($this->dbi->isSuperUser()) {
|
||||
$this->dbi->selectDb('mysql');
|
||||
}
|
||||
|
||||
$position = ! empty($params['pos']) ? (int) $params['pos'] : 0;
|
||||
|
||||
$urlParams = [];
|
||||
if (isset($params['log']) && array_key_exists($params['log'], $this->binaryLogs)) {
|
||||
$urlParams['log'] = $params['log'];
|
||||
if (array_key_exists($log, $this->binaryLogs)) {
|
||||
$urlParams['log'] = $log;
|
||||
}
|
||||
|
||||
$isFullQuery = false;
|
||||
if (! empty($params['is_full_query'])) {
|
||||
if ($request->hasBodyParam('is_full_query')) {
|
||||
$isFullQuery = true;
|
||||
$urlParams['is_full_query'] = 1;
|
||||
}
|
||||
|
||||
$sqlQuery = $this->getSqlQuery($params['log'] ?? '', $position, (int) $GLOBALS['cfg']['MaxRows']);
|
||||
$sqlQuery = $this->getSqlQuery($log ?? '', $position, (int) $GLOBALS['cfg']['MaxRows']);
|
||||
$result = $this->dbi->query($sqlQuery);
|
||||
|
||||
$numRows = $result->numRows();
|
||||
@ -99,7 +93,7 @@ class BinlogController extends AbstractController
|
||||
$this->render('server/binlog/index', [
|
||||
'url_params' => $urlParams,
|
||||
'binary_logs' => $this->binaryLogs,
|
||||
'log' => $params['log'],
|
||||
'log' => $log,
|
||||
'sql_message' => Generator::getMessage(Message::success(), $sqlQuery),
|
||||
'values' => $values,
|
||||
'has_previous' => $position > 0,
|
||||
@ -123,7 +117,7 @@ class BinlogController extends AbstractController
|
||||
int $maxRows
|
||||
): string {
|
||||
$sqlQuery = 'SHOW BINLOG EVENTS';
|
||||
if (! empty($log)) {
|
||||
if ($log !== '') {
|
||||
$sqlQuery .= ' IN \'' . $log . '\'';
|
||||
}
|
||||
|
||||
|
||||
@ -1395,6 +1395,21 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/SchemaExportController.php
|
||||
|
||||
-
|
||||
message: "#^Cannot cast mixed to int\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/BinlogController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$key of function array_key_exists expects int\\|string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/BinlogController.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$log of method PhpMyAdmin\\\\Controllers\\\\Server\\\\BinlogController\\:\\:getSqlQuery\\(\\) expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Controllers/Server/BinlogController.php
|
||||
|
||||
-
|
||||
message: "#^Property PhpMyAdmin\\\\Controllers\\\\Server\\\\BinlogController\\:\\:\\$binaryLogs type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
|
||||
@ -2583,22 +2583,17 @@
|
||||
</MixedArgument>
|
||||
</file>
|
||||
<file src="libraries/classes/Controllers/Server/BinlogController.php">
|
||||
<MixedAssignment occurrences="1">
|
||||
<code>$GLOBALS['errorUrl']</code>
|
||||
<MixedArgument occurrences="2">
|
||||
<code>$log</code>
|
||||
<code>$log ?? ''</code>
|
||||
</MixedArgument>
|
||||
<MixedAssignment occurrences="2">
|
||||
<code>$log</code>
|
||||
<code>$urlParams['log']</code>
|
||||
</MixedAssignment>
|
||||
<PossiblyInvalidArgument occurrences="2">
|
||||
<code>$params['log']</code>
|
||||
<code>$params['log'] ?? ''</code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyInvalidCast occurrences="1">
|
||||
<code>$params['log'] ?? ''</code>
|
||||
</PossiblyInvalidCast>
|
||||
<RedundantCast occurrences="1">
|
||||
<code>(int) $GLOBALS['cfg']['MaxRows']</code>
|
||||
</RedundantCast>
|
||||
<RiskyCast occurrences="1">
|
||||
<code>$params['pos']</code>
|
||||
</RiskyCast>
|
||||
</file>
|
||||
<file src="libraries/classes/Controllers/Server/Databases/CreateController.php">
|
||||
<MixedAssignment occurrences="1">
|
||||
|
||||
@ -53,10 +53,13 @@ class BinlogControllerTest extends AbstractTestCase
|
||||
|
||||
$controller = new BinlogController($response, new Template(), $GLOBALS['dbi']);
|
||||
|
||||
$_POST['log'] = 'index1';
|
||||
$_POST['pos'] = '3';
|
||||
$request = $this->createStub(ServerRequest::class);
|
||||
$request->method('getParsedBodyParam')->willReturnMap([
|
||||
['log', null, 'index1'],
|
||||
['pos', 0, '3'],
|
||||
]);
|
||||
$this->dummyDbi->addSelectDb('mysql');
|
||||
$controller($this->createStub(ServerRequest::class));
|
||||
$controller($request);
|
||||
$this->dummyDbi->assertAllSelectsConsumed();
|
||||
$actual = $response->getHTMLResult();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user