Issue #1998330 by clemens.tolboom, dawehner: Fixed Minipager is broken on page size == 1 due to ceil(PHP_MAX_INT / 1).
parent
421bee5b4a
commit
262895e9da
|
@ -82,8 +82,9 @@ class Mini extends SqlBase {
|
||||||
if (count($result) > $this->get_items_per_page()) {
|
if (count($result) > $this->get_items_per_page()) {
|
||||||
array_pop($result);
|
array_pop($result);
|
||||||
// Make sure the pager shows the next link by setting the total items to
|
// Make sure the pager shows the next link by setting the total items to
|
||||||
// the biggest possible number.
|
// the biggest possible number but prevent failing calculations like
|
||||||
pager_default_initialize(PHP_INT_MAX, $this->get_items_per_page(), $this->options['id']);
|
// 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 @@ class MiniPagerTest extends PluginTestBase {
|
||||||
$this->assertText($this->nodes[18]->label());
|
$this->assertText($this->nodes[18]->label());
|
||||||
$this->assertText($this->nodes[19]->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.
|
// Remove all items beside 1, so there should be no links shown.
|
||||||
for ($i = 0; $i < 19; $i++) {
|
for ($i = 0; $i < 19; $i++) {
|
||||||
$this->nodes[$i]->delete();
|
$this->nodes[$i]->delete();
|
||||||
|
|
|
@ -84,6 +84,19 @@ display:
|
||||||
position: ''
|
position: ''
|
||||||
display_options:
|
display_options:
|
||||||
path: test_mini_pager
|
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
|
base_field: nid
|
||||||
status: '1'
|
status: '1'
|
||||||
module: views
|
module: views
|
||||||
|
|
Loading…
Reference in New Issue