Issue #1998330 by clemens.tolboom, dawehner: Fixed Minipager is broken on page size == 1 due to ceil(PHP_MAX_INT / 1).

8.0.x
Alex Pott 2013-05-28 23:06:06 +01:00
parent 421bee5b4a
commit 262895e9da
3 changed files with 34 additions and 2 deletions

View File

@ -82,8 +82,9 @@ class Mini extends SqlBase {
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']);
}
}

View File

@ -73,6 +73,24 @@ class MiniPagerTest extends PluginTestBase {
$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();

View File

@ -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