Quantcast
Viewing all articles
Browse latest Browse all 294646

Minipager is broken on page size == 1 due to ceil(PHP_MAX_INT / 1)

When calculating

<?php
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

<?php
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.

<?php
class Mini
...
  public function
postExecute(&$result) {
    ...
   
pager_default_initialize(PHP_INT_MAX / 2, $this->get_items_per_page(), $this->options['id']);
?>
AttachmentSizeStatusTest resultOperations
core-fix-mini-pager-on-single-item.patch718 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 55,742 pass(es).View details | Re-test

Viewing all articles
Browse latest Browse all 294646

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>