diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fbfebbbe21..3f12712fe1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6252,6 +6252,12 @@ parameters: count: 1 path: src/Display/Results.php + - + message: '#^Binary operation "\+" between mixed and int\|numeric\-string results in an error\.$#' + identifier: binaryOp.invalid + count: 1 + path: src/Display/Results.php + - message: '#^Binary operation "\+" between mixed and mixed results in an error\.$#' identifier: binaryOp.invalid @@ -6321,7 +6327,7 @@ parameters: - message: '#^Cannot access offset ''max_rows'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible - count: 18 + count: 19 path: src/Display/Results.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9c09c6f759..367b9e7c91 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -4087,6 +4087,7 @@ + diff --git a/src/Display/Results.php b/src/Display/Results.php index 92006e5b5f..596238cbef 100644 --- a/src/Display/Results.php +++ b/src/Display/Results.php @@ -616,8 +616,9 @@ class Results $isLastPage = $this->unlimNumRows !== -1 && $this->unlimNumRows !== false && ($isShowingAll - || (int) $_SESSION['tmpval']['pos'] + (int) $_SESSION['tmpval']['max_rows'] - >= $this->unlimNumRows + || ($this->isExactCount() + && (int) $_SESSION['tmpval']['pos'] + (int) $_SESSION['tmpval']['max_rows'] + >= $this->unlimNumRows) || $this->numRows < $_SESSION['tmpval']['max_rows']); $onsubmit = ' onsubmit="return ' @@ -663,6 +664,15 @@ class Results ]; } + private function isExactCount(): bool + { + // If we have the full page of rows, we don't know + // if there are more unless unlimNumRows is smaller than MaxExactCount + return $this->unlimNumRows < $this->config->settings['MaxExactCount'] + || $_SESSION['tmpval']['max_rows'] === self::ALL_ROWS + || $this->numRows < $_SESSION['tmpval']['max_rows']; + } + /** * Get the headers of the results table, for all of the columns * @@ -3383,7 +3393,7 @@ class Results } } elseif ($_SESSION['tmpval']['max_rows'] === self::ALL_ROWS || $posNext > $total) { $firstShownRec = $_SESSION['tmpval']['pos']; - $lastShownRec = $total - 1; + $lastShownRec = $firstShownRec + $this->numRows - 1; } else { $firstShownRec = $_SESSION['tmpval']['pos']; $lastShownRec = $posNext - 1;