fix: PaginatorHelper::numbers() generates extra separator string in PHP 8.0+.

This commit is contained in:
Koji Tanaka 2023-01-29 22:48:42 +09:00 committed by Kamil Wylegala
parent 3d32e313c0
commit 1d1750ae8c
2 changed files with 2 additions and 6 deletions

View file

@ -1493,11 +1493,6 @@ class PaginatorHelperTest extends CakeTestCase {
* @return void
*/
public function testNumbers() {
// In PHP 8.0, the behavior of comparison operators has changed
// and the behavior of $offset = "last" has changed. So the test fails.
if (PHP_MAJOR_VERSION >= 8) {
$this->markTestIncomplete('In PHP 8.0, fail test.');
}
$this->Paginator->request->params['paging'] = array(
'Client' => array(
'page' => 8,

View file

@ -822,7 +822,8 @@ class PaginatorHelper extends AppHelper {
if ($last && $end < $params['pageCount']) {
$lastPage = is_int($last) ? $last : 0;
$offset = ($params['pageCount'] < $end + $lastPage) ? $params['pageCount'] - $end : $last;
if ($offset <= $lastPage && $params['pageCount'] - $end > $lastPage) {
$offsetIsLabel = (!is_int($offset) && !ctype_digit($offset));
if (($offsetIsLabel || $offset <= $lastPage) && $params['pageCount'] - $end > $lastPage) {
$out .= $this->last($offset, compact('tag', 'separator', 'ellipsis', 'class'));
} else {
$out .= $this->last($offset, compact('tag', 'separator', 'class', 'ellipsis') + array('before' => $separator));