Commit 262895e9 authored by alexpott's avatar alexpott

Issue #1998330 by clemens.tolboom, dawehner: Fixed Minipager is broken on page...

Issue #1998330 by clemens.tolboom, dawehner: Fixed Minipager is broken on page size == 1 due to ceil(PHP_MAX_INT / 1).
parent 421bee5b
......@@ -82,8 +82,9 @@ public function postExecute(&$result) {
if (count($result) > $this->get_items_per_page()) {
array_pop($result);
// Make sure the pager shows the next link by setting the total items to
// the biggest possible number.
pager_default_initialize(PHP_INT_MAX, $this->get_items_per_page(), $this->options['id']);
// the biggest possible number but prevent failing calculations like
// ceil(PHP_INT_MAX) we take PHP_INT_MAX / 2.
pager_default_initialize(PHP_INT_MAX / 2, $this->get_items_per_page(), $this->options['id']);
}
}
......
......@@ -73,6 +73,24 @@ public function testMiniPagerRender() {
$this->assertText($this->nodes[18]->label());
$this->assertText($this->nodes[19]->label());
// Test a mini pager with just one item per page.
$this->drupalGet('test_mini_pager_one');
$this->assertText('››');
$this->assertText('Page 1');
$this->assertText($this->nodes[0]->label());
$this->drupalGet('test_mini_pager_one', array('query' => array('page' => 1)));
$this->assertText('‹‹');
$this->assertText('Page 2');
$this->assertText('››');
$this->assertText($this->nodes[1]->label());
$this->drupalGet('test_mini_pager_one', array('query' => array('page' => 19)));
$this->assertNoText('››');
$this->assertText('Page 20');
$this->assertText('‹‹');
$this->assertText($this->nodes[19]->label());
// Remove all items beside 1, so there should be no links shown.
for ($i = 0; $i < 19; $i++) {
$this->nodes[$i]->delete();
......
......@@ -84,6 +84,19 @@ display:
position: ''
display_options:
path: test_mini_pager
page_2:
display_plugin: page
id: page_2
display_title: Page
position: ''
display_options:
path: test_mini_pager_one
defaults:
pager: '0'
pager:
type: mini
options:
items_per_page: '1'
base_field: nid
status: '1'
module: views
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment