diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index b83561d24..a28767364 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -782,7 +782,7 @@ class PaginatorHelper extends AppHelper { } } $out .= $after; - } elseif ($params['page'] > 1) { + } elseif ($params['page'] > 1 && is_string($first)) { $options += array('rel' => 'first'); $out = $this->Html->tag($tag, $this->link($first, array('page' => 1), $options)) . $after; @@ -848,7 +848,7 @@ class PaginatorHelper extends AppHelper { } } $out = $before . $out; - } elseif ($params['page'] < $params['pageCount']) { + } elseif ($params['page'] < $params['pageCount'] && is_string($last)) { $options += array('rel' => 'last'); $out = $before . $this->Html->tag( $tag, $this->link($last, array('page' => $params['pageCount']), $options diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/cake/tests/cases/libs/view/helpers/paginator.test.php index 7b600819f..ce4497536 100644 --- a/cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/cake/tests/cases/libs/view/helpers/paginator.test.php @@ -1878,6 +1878,10 @@ class PaginatorHelperTest extends CakeTestCase { '/span' ); $this->assertTags($result, $expected); + + $this->Paginator->request->params['paging']['Article']['page'] = 2; + $result = $this->Paginator->first(3); + $this->assertEquals('', $result, 'When inside the first links range, no links should be made'); } /** @@ -1922,6 +1926,9 @@ class PaginatorHelperTest extends CakeTestCase { '/span', ); $this->assertTags($result, $expected); + + $result = $this->Paginator->last(3); + $this->assertEquals('', $result, 'When inside the last links range, no links should be made'); } /**