Merge pull request #19586 from kamil-tekiela/Fix-views-row-count
Fix view row count
This commit is contained in:
commit
6aa387cc0c
@ -6381,7 +6381,7 @@ parameters:
|
||||
-
|
||||
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
|
||||
identifier: equal.notAllowed
|
||||
count: 8
|
||||
count: 7
|
||||
path: src/Display/Results.php
|
||||
|
||||
-
|
||||
@ -6528,12 +6528,6 @@ parameters:
|
||||
count: 2
|
||||
path: src/Display/Results.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$value of static method PhpMyAdmin\\Util\:\:formatNumber\(\) expects float\|int\|string, int\|string\|false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Display/Results.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$field of class PhpMyAdmin\\Display\\ForeignKeyRelatedTable constructor expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
@ -6636,12 +6630,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Display/Results.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Display\\Results\:\:\$unlimNumRows \(int\|numeric\-string\|false\) is never assigned false so it can be removed from the property type\.$#'
|
||||
identifier: property.unusedType
|
||||
count: 1
|
||||
path: src/Display/Results.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\FieldMetadata\:\:\$name \(string\) does not accept mixed\.$#'
|
||||
identifier: assign.propertyType
|
||||
|
||||
@ -112,9 +112,9 @@ class Results
|
||||
/**
|
||||
* the total number of rows returned by the SQL query without any appended "LIMIT" clause programmatically
|
||||
*
|
||||
* @var int|numeric-string|false
|
||||
* @var int|numeric-string
|
||||
*/
|
||||
private int|string|false $unlimNumRows = 0;
|
||||
private int|string $unlimNumRows = 0;
|
||||
|
||||
/**
|
||||
* meta information about fields
|
||||
@ -613,7 +613,7 @@ class Results
|
||||
[$pageSelector, $numberTotalPage] = $this->getHtmlPageSelector();
|
||||
}
|
||||
|
||||
$isLastPage = $this->unlimNumRows !== -1 && $this->unlimNumRows !== false
|
||||
$isLastPage = $this->unlimNumRows !== -1
|
||||
&& ($isShowingAll
|
||||
|| ($this->isExactCount()
|
||||
&& (int) $_SESSION['tmpval']['pos'] + (int) $_SESSION['tmpval']['max_rows']
|
||||
@ -658,7 +658,7 @@ class Results
|
||||
'pos_next' => $posNext,
|
||||
'pos_last' => $posLast,
|
||||
'is_last_page' => $isLastPage,
|
||||
'is_last_page_known' => $this->unlimNumRows !== false,
|
||||
'is_last_page_known' => $this->unlimNumRows !== -1,
|
||||
'onsubmit' => $onsubmit,
|
||||
];
|
||||
}
|
||||
@ -3348,8 +3348,6 @@ class Results
|
||||
string $preCount,
|
||||
string $afterCount,
|
||||
): Message {
|
||||
$unlimNumRows = $this->unlimNumRows; // To use in isset()
|
||||
|
||||
if (! empty($statementInfo->statement->limit)) {
|
||||
$firstShownRec = $statementInfo->statement->limit->offset;
|
||||
$rowCount = $statementInfo->statement->limit->rowCount;
|
||||
@ -3369,7 +3367,7 @@ class Results
|
||||
|
||||
$messageViewWarning = false;
|
||||
$table = new Table($this->table, $this->db, $this->dbi);
|
||||
if ($table->isView() && $total == $this->config->settings['MaxExactCountViews']) {
|
||||
if ($table->isView() && $total === -1) {
|
||||
$message = Message::notice(
|
||||
__(
|
||||
'This view has at least this number of rows. Please refer to %sdocumentation%s.',
|
||||
@ -3393,12 +3391,12 @@ class Results
|
||||
$message->addText('(');
|
||||
|
||||
if ($messageViewWarning === false) {
|
||||
if ($unlimNumRows != $total) {
|
||||
if ($this->unlimNumRows != $total) {
|
||||
$messageTotal = Message::notice(
|
||||
$preCount . __('%1$s total, %2$s in query'),
|
||||
);
|
||||
$messageTotal->addParam(Util::formatNumber($total, 0));
|
||||
$messageTotal->addParam(Util::formatNumber($unlimNumRows, 0));
|
||||
$messageTotal->addParam(Util::formatNumber($this->unlimNumRows, 0));
|
||||
} else {
|
||||
$messageTotal = Message::notice($preCount . __('%s total'));
|
||||
$messageTotal->addParam(Util::formatNumber($total, 0));
|
||||
|
||||
@ -666,7 +666,7 @@ class Table implements Stringable
|
||||
// count could bring down a server, so we offer an
|
||||
// alternative: setting MaxExactCountViews to 0 will bypass
|
||||
// completely the record counting for views
|
||||
$rowCount = false;
|
||||
return -1;
|
||||
} else {
|
||||
// Counting all rows of a VIEW could be too long,
|
||||
// so use a LIMIT clause.
|
||||
@ -679,6 +679,10 @@ class Table implements Stringable
|
||||
);
|
||||
if ($result) {
|
||||
$rowCount = $result->numRows();
|
||||
if ((int) $rowCount === $config->settings['MaxExactCountViews']) {
|
||||
// If we reached the limit, we can't be sure how many rows there are
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -688,7 +692,7 @@ class Table implements Stringable
|
||||
return (int) $rowCount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user