Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
When calculating ceil($pager_total_items[$element] / $limit);
for a mini pager which is equal to -9223372036854775808 by running $ php -r "echo (int) ceil(PHP_INT_MAX/1);"
we need to either fix the ceil code in
function pager_default_initialize($total, $limit, $element = 0) {
global $pager_page_array, $pager_total, $pager_total_items, $pager_limits;
$page = pager_find_page($element);
// We calculate the total of pages as ceil(items / limit).
$pager_total_items[$element] = $total;
$pager_total[$element] = ceil($pager_total_items[$element] / $limit);
or fix the initialization of $total to PHP_MAX_INT / 2 in which seems better.
class Mini
...
public function postExecute(&$result) {
...
pager_default_initialize(PHP_INT_MAX / 2, $this->get_items_per_page(), $this->options['id']);
Comment | File | Size | Author |
---|---|---|---|
#5 | drupal-1998330-5.patch | 2.98 KB | dawehner |
#3 | core-fix-mini-pager-on-single-item-1998330-2.patch | 3.32 KB | clemens.tolboom |
core-fix-mini-pager-on-single-item.patch | 718 bytes | clemens.tolboom | |
Comments
Comment #1
clemens.tolboomCode seems to be added to core through #1901290: Replace the mini pager with a lite pager (which does not run a count query) which is rather new Feb 18, 2013.
Comment #2
jibranTagging.
Comment #3
clemens.tolboomI've rewritten the mini page test to accommodate this failure.
Comment #4
clemens.tolboomRestoring the VDC tag.
Comment #5
dawehnerThanks for fixing the issue. I used your tests to provide a separate test coverage just to ensure that it's working both with 3 and 1 items per page,
because 1 item per page actually feels a bit like an edge case.
Comment #6
clemens.tolboomWe have to decide what's the best maximum. I did some more testing
so we are safe using
PHP_INT_MAX / 2
but is that ok?Comment #7
dawehnerYour current bit is consistent on all php versions: http://3v4l.org/gE3gE
The main thing I care about at that point: Make the piece of code understandable to we don't run into the same problem again.
Comment #8
damiankloip CreditAttribution: damiankloip commentedI think I agree with keeping it simple, and this method will work just fine too.
Comment #9
alexpottCommitted 262895e and pushed to 8.x. Thanks!