Skip to content

Commit

Permalink
Merge branch 'QA_5_2'
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
  • Loading branch information
MauricioFauth committed Dec 25, 2024
2 parents 3355837 + 9ee8e20 commit 081d6c1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 38 deletions.
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ parameters:
-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
count: 5
count: 3
path: src/Controllers/Database/StructureController.php

-
Expand Down Expand Up @@ -16081,7 +16081,7 @@ parameters:
path: src/Sql.php

-
message: '#^Parameter \#9 \$queryTime of method PhpMyAdmin\\Display\\Results\:\:setProperties\(\) expects float, mixed given\.$#'
message: '#^Parameter \#8 \$queryTime of method PhpMyAdmin\\Display\\Results\:\:setProperties\(\) expects float, mixed given\.$#'
identifier: argument.type
count: 2
path: src/Sql.php
Expand Down
9 changes: 2 additions & 7 deletions src/Display/DisplayParts.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ private function __construct(
public bool $hasBookmarkForm,
public bool $hasTextButton,
public bool $hasPrintLink,
public bool $hasQueryStats,
) {
}

Expand All @@ -28,8 +27,7 @@ private function __construct(
* hasNavigationBar?: bool,
* hasBookmarkForm?: bool,
* hasTextButton?: bool,
* hasPrintLink?: bool,
* hasQueryStats?: bool
* hasPrintLink?: bool
* } $parts
*/
public static function fromArray(array $parts): self
Expand All @@ -42,7 +40,6 @@ public static function fromArray(array $parts): self
$parts['hasBookmarkForm'] ?? false,
$parts['hasTextButton'] ?? false,
$parts['hasPrintLink'] ?? false,
$parts['hasQueryStats'] ?? false,
);
}

Expand All @@ -55,8 +52,7 @@ public static function fromArray(array $parts): self
* hasNavigationBar?: bool,
* hasBookmarkForm?: bool,
* hasTextButton?: bool,
* hasPrintLink?: bool,
* hasQueryStats?: bool
* hasPrintLink?: bool
* } $parts
*/
public function with(array $parts): self
Expand All @@ -69,7 +65,6 @@ public function with(array $parts): self
$parts['hasBookmarkForm'] ?? $this->hasBookmarkForm,
$parts['hasTextButton'] ?? $this->hasTextButton,
$parts['hasPrintLink'] ?? $this->hasPrintLink,
$parts['hasQueryStats'] ?? $this->hasQueryStats,
);
}
}
17 changes: 5 additions & 12 deletions src/Display/Results.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class Results
private bool $editable = false;
private bool $printView = false;
private bool $isCount = false;
private bool $isGroup = false;
private bool $isExport = false;
private bool $isFunction = false;
private bool $isAnalyse = false;
Expand Down Expand Up @@ -317,7 +316,6 @@ private function setDefaultTransformations(): void
* any appended "LIMIT" clause programmatically
* @param FieldMetadata[] $fieldsMeta meta information about fields
* @param bool $isCount statement is SELECT COUNT
* @param bool $isGroup statement has GROUP BY
* @param bool $isExport statement contains INTO OUTFILE
* @param bool $isFunction statement contains a function like SUM()
* @param bool $isAnalyse statement contains PROCEDURE ANALYSE
Expand All @@ -336,7 +334,6 @@ public function setProperties(
int|string $unlimNumRows,
array $fieldsMeta,
bool $isCount,
bool $isGroup,
bool $isExport,
bool $isFunction,
bool $isAnalyse,
Expand All @@ -352,7 +349,6 @@ public function setProperties(
$this->unlimNumRows = $unlimNumRows;
$this->fieldsMeta = $fieldsMeta;
$this->isCount = $isCount;
$this->isGroup = $isGroup;
$this->isExport = $isExport;
$this->isFunction = $isFunction;
$this->isAnalyse = $isAnalyse;
Expand All @@ -379,7 +375,6 @@ private function setDisplayPartsForPrintView(DisplayParts $displayParts): Displa
'hasBookmarkForm' => false,
'hasTextButton' => false,
'hasPrintLink' => false,
'hasQueryStats' => true,
]);
}

Expand Down Expand Up @@ -409,7 +404,6 @@ private function setDisplayPartsForShow(DisplayParts $displayParts): DisplayPart
'hasBookmarkForm' => true,
'hasTextButton' => true,
'hasPrintLink' => true,
'hasQueryStats' => false,
]);
}

Expand All @@ -429,7 +423,6 @@ private function setDisplayPartsForNonData(DisplayParts $displayParts): DisplayP
'hasBookmarkForm' => true,
'hasTextButton' => $this->isMaintenance,
'hasPrintLink' => true,
'hasQueryStats' => false,
]);
}

Expand Down Expand Up @@ -502,7 +495,7 @@ private function setDisplayPartsAndTotal(DisplayParts $displayParts): array
// 2. Updates the display parts
if ($this->printView) {
$displayParts = $this->setDisplayPartsForPrintView($displayParts);
} elseif ($this->isAnalyse || $this->isMaintenance || $this->isExplain) {
} elseif ($this->isCount || $this->isAnalyse || $this->isMaintenance || $this->isExplain) {

Check warning on line 498 in src/Display/Results.php

View workflow job for this annotation

GitHub Actions / Infection (8.2, ubuntu-latest)

Escaped Mutant for Mutator "LogicalOr": --- Original +++ New @@ @@ // 2. Updates the display parts if ($this->printView) { $displayParts = $this->setDisplayPartsForPrintView($displayParts); - } elseif ($this->isCount || $this->isAnalyse || $this->isMaintenance || $this->isExplain) { + } elseif ($this->isCount && $this->isAnalyse || $this->isMaintenance || $this->isExplain) { $displayParts = $this->setDisplayPartsForNonData($displayParts); } elseif ($this->isShow) { $displayParts = $this->setDisplayPartsForShow($displayParts);

Check warning on line 498 in src/Display/Results.php

View workflow job for this annotation

GitHub Actions / Infection (8.2, ubuntu-latest)

Escaped Mutant for Mutator "LogicalOr": --- Original +++ New @@ @@ // 2. Updates the display parts if ($this->printView) { $displayParts = $this->setDisplayPartsForPrintView($displayParts); - } elseif ($this->isCount || $this->isAnalyse || $this->isMaintenance || $this->isExplain) { + } elseif (($this->isCount || $this->isAnalyse) && $this->isMaintenance || $this->isExplain) { $displayParts = $this->setDisplayPartsForNonData($displayParts); } elseif ($this->isShow) { $displayParts = $this->setDisplayPartsForShow($displayParts);

Check warning on line 498 in src/Display/Results.php

View workflow job for this annotation

GitHub Actions / Infection (8.2, ubuntu-latest)

Escaped Mutant for Mutator "LogicalOr": --- Original +++ New @@ @@ // 2. Updates the display parts if ($this->printView) { $displayParts = $this->setDisplayPartsForPrintView($displayParts); - } elseif ($this->isCount || $this->isAnalyse || $this->isMaintenance || $this->isExplain) { + } elseif (($this->isCount || $this->isAnalyse || $this->isMaintenance) && $this->isExplain) { $displayParts = $this->setDisplayPartsForNonData($displayParts); } elseif ($this->isShow) { $displayParts = $this->setDisplayPartsForShow($displayParts);
$displayParts = $this->setDisplayPartsForNonData($displayParts);
} elseif ($this->isShow) {
$displayParts = $this->setDisplayPartsForShow($displayParts);
Expand All @@ -523,8 +516,8 @@ private function setDisplayPartsAndTotal(DisplayParts $displayParts): array

// if for COUNT query, number of rows returned more than 1
// (may be being used GROUP BY)
if ($this->isCount && ! $this->isGroup) {
$displayParts = $displayParts->with(['hasNavigationBar' => false, 'hasSortLink' => false]);
if ($this->isCount && $this->numRows > 1) {

Check warning on line 519 in src/Display/Results.php

View workflow job for this annotation

GitHub Actions / Infection (8.2, ubuntu-latest)

Escaped Mutant for Mutator "GreaterThan": --- Original +++ New @@ @@ } // if for COUNT query, number of rows returned more than 1 // (may be being used GROUP BY) - if ($this->isCount && $this->numRows > 1) { + if ($this->isCount && $this->numRows >= 1) { $displayParts = $displayParts->with(['hasNavigationBar' => true, 'hasSortLink' => true]); } // 4. If navigation bar or sorting fields names URLs should be

Check warning on line 519 in src/Display/Results.php

View workflow job for this annotation

GitHub Actions / Infection (8.2, ubuntu-latest)

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ } // if for COUNT query, number of rows returned more than 1 // (may be being used GROUP BY) - if ($this->isCount && $this->numRows > 1) { + if ($this->isCount || $this->numRows > 1) { $displayParts = $displayParts->with(['hasNavigationBar' => true, 'hasSortLink' => true]); } // 4. If navigation bar or sorting fields names URLs should be
$displayParts = $displayParts->with(['hasNavigationBar' => true, 'hasSortLink' => true]);
}

// 4. If navigation bar or sorting fields names URLs should be
Expand Down Expand Up @@ -3089,7 +3082,7 @@ public function getTable(
// 1.2 Defines offsets for the next and previous pages
$posNext = 0;
$posPrev = 0;
if ($displayParts->hasNavigationBar || $displayParts->hasQueryStats) {
if ($displayParts->hasNavigationBar) {
[$posNext, $posPrev] = $this->getOffsets();
}

Expand Down Expand Up @@ -3122,7 +3115,7 @@ public function getTable(

// 2.1 Prepares a messages with position information
$sqlQueryMessage = '';
if ($displayParts->hasQueryStats && $total > 0) {
if ($displayParts->hasNavigationBar) {
$message = $this->setMessageInformation(
$sortedColumnMessage,
$statementInfo,
Expand Down
7 changes: 0 additions & 7 deletions src/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,6 @@ private function getQueryResponseForNoResultsReturned(
'hasBookmarkForm' => true,
'hasTextButton' => true,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);

$sqlQueryResultsTable = $this->getHtmlForSqlQueryResultsTable(
Expand Down Expand Up @@ -1106,7 +1105,6 @@ private function getHtmlForSqlQueryResultsTable(
$unlimNumRows,
$this->dbi->getFieldsMeta($result),
$statementInfo->flags->isCount,
$statementInfo->flags->isGroup,
$statementInfo->flags->isExport,
$statementInfo->flags->isFunc,
$statementInfo->flags->isAnalyse,
Expand Down Expand Up @@ -1142,7 +1140,6 @@ private function getHtmlForStoredProcedureResults(
$numRows,
$this->dbi->getFieldsMeta($result),
$statementInfo->flags->isCount,
$statementInfo->flags->isGroup,
$statementInfo->flags->isExport,
$statementInfo->flags->isFunc,
$statementInfo->flags->isAnalyse,
Expand All @@ -1164,7 +1161,6 @@ private function getHtmlForStoredProcedureResults(
'hasBookmarkForm' => true,
'hasTextButton' => true,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);

$tableHtml .= $displayResultsObject->getTable(
Expand Down Expand Up @@ -1347,7 +1343,6 @@ private function getQueryResponseForResultsReturned(
'hasBookmarkForm' => true,
'hasTextButton' => false,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);

if (! $editable) {
Expand All @@ -1359,7 +1354,6 @@ private function getQueryResponseForResultsReturned(
'hasBookmarkForm' => true,
'hasTextButton' => true,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);
}

Expand All @@ -1372,7 +1366,6 @@ private function getQueryResponseForResultsReturned(
'hasBookmarkForm' => false,
'hasTextButton' => false,
'hasPrintLink' => false,
'hasQueryStats' => false,
]);
}

Expand Down
6 changes: 0 additions & 6 deletions tests/unit/Display/DisplayPartsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function testFromArray(): void
'hasBookmarkForm' => true,
'hasTextButton' => true,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);
self::assertTrue($displayParts->hasEditLink);
self::assertSame(DeleteLinkEnum::DELETE_ROW, $displayParts->deleteLink);
Expand All @@ -31,7 +30,6 @@ public function testFromArray(): void
self::assertTrue($displayParts->hasBookmarkForm);
self::assertTrue($displayParts->hasTextButton);
self::assertTrue($displayParts->hasPrintLink);
self::assertTrue($displayParts->hasQueryStats);
}

public function testWith(): void
Expand All @@ -44,7 +42,6 @@ public function testWith(): void
self::assertFalse($displayParts->hasBookmarkForm);
self::assertFalse($displayParts->hasTextButton);
self::assertFalse($displayParts->hasPrintLink);
self::assertFalse($displayParts->hasQueryStats);

$displayParts = $displayParts->with([
'hasEditLink' => true,
Expand All @@ -54,7 +51,6 @@ public function testWith(): void
'hasBookmarkForm' => true,
'hasTextButton' => true,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);
self::assertTrue($displayParts->hasEditLink);
self::assertSame(DeleteLinkEnum::KILL_PROCESS, $displayParts->deleteLink);
Expand All @@ -63,7 +59,6 @@ public function testWith(): void
self::assertTrue($displayParts->hasBookmarkForm);
self::assertTrue($displayParts->hasTextButton);
self::assertTrue($displayParts->hasPrintLink);
self::assertTrue($displayParts->hasQueryStats);

$displayParts = $displayParts->with([]);
self::assertTrue($displayParts->hasEditLink);
Expand All @@ -73,6 +68,5 @@ public function testWith(): void
self::assertTrue($displayParts->hasBookmarkForm);
self::assertTrue($displayParts->hasTextButton);
self::assertTrue($displayParts->hasPrintLink);
self::assertTrue($displayParts->hasQueryStats);
}
}
4 changes: 0 additions & 4 deletions tests/unit/Display/ResultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,6 @@ public function testGetTable(): void
3,
$fieldsMeta,
$statementInfo->flags->isCount,
$statementInfo->flags->isGroup,
$statementInfo->flags->isExport,
$statementInfo->flags->isFunc,
$statementInfo->flags->isAnalyse,
Expand Down Expand Up @@ -1215,7 +1214,6 @@ public function testGetTable(): void
'hasBookmarkForm' => true,
'hasTextButton' => false,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);

self::assertNotFalse($dtResult);
Expand Down Expand Up @@ -1472,7 +1470,6 @@ public function testGetTable2(): void
2,
$fieldsMeta,
$statementInfo->flags->isCount,
$statementInfo->flags->isGroup,
$statementInfo->flags->isExport,
$statementInfo->flags->isFunc,
$statementInfo->flags->isAnalyse,
Expand Down Expand Up @@ -1509,7 +1506,6 @@ public function testGetTable2(): void
'hasBookmarkForm' => true,
'hasTextButton' => false,
'hasPrintLink' => true,
'hasQueryStats' => true,
]);

self::assertNotFalse($dtResult);
Expand Down

0 comments on commit 081d6c1

Please sign in to comment.