Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have an error with Division by zero in views_handler_area_result->render() (line 66 of .../sites/all/modules/views/handlers/views_handler_area_result.inc). (there is 1 comment about problem but in other issue - http://drupal.org/node/1418258#comment-5522094
It is because of when we are using view with full list of items and without pages, we set "items per page = 0" in options and when we are using summary result it causes error
$page_count = (int) ceil($total / $per_page); //here line 66
if ($per_page === 0) {
$start = 1;
$end = $total;
}
else {
$total_count = $current_page * $per_page;
if ($total_count > $total) {
$total_count = $total;
}
$start = ($current_page - 1) * $per_page + 1;
$end = $total_count;
}
I think it should be like this
$page_count = 0;
if ($per_page === 0) {
$start = 1;
$end = $total;
}
else {
$page_count = (int) ceil($total / $per_page);
$total_count = $current_page * $per_page;
if ($total_count > $total) {
$total_count = $total;
}
$start = ($current_page - 1) * $per_page + 1;
$end = $total_count;
}
Comment | File | Size | Author |
---|---|---|---|
#1 | 1418852.patch | 2.99 KB | dawehner |
Comments
Comment #1
dawehnerWhat about setting $page_count to 1 if there is just one page (0 items per page).
This also corrects the indentation of the file.
Comment #2
jtse CreditAttribution: jtse commented#1's patch works for me.
Comment #3
dawehnerJust committed it to 7.x-3.x
Comment #4
bucephalus CreditAttribution: bucephalus commentedIt doesn't work if you have selected - all- choice of the dropdown in number of records. I´ve made this code to tackle this problem and it works.
regards.
Comment #6
scor CreditAttribution: scor commentedhitting the same problem as @bucephalus in #4.
Comment #7
scor CreditAttribution: scor commentedignore previous comment, seems to be working in views -dev.