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;
      }
CommentFileSizeAuthor
#1 1418852.patch2.99 KBdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
2.99 KB

What about setting $page_count to 1 if there is just one page (0 items per page).

This also corrects the indentation of the file.

jtse’s picture

#1's patch works for me.

dawehner’s picture

Status: Needs review » Fixed

Just committed it to 7.x-3.x

bucephalus’s picture

It 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.

if ($per_page === 0) {
		$per_page = 1;
      }
	  $page_count = (int) ceil($total / $per_page);
      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;
      }<?php

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

scor’s picture

Status: Closed (fixed) » Active

hitting the same problem as @bucephalus in #4.

scor’s picture

Status: Active » Closed (fixed)

ignore previous comment, seems to be working in views -dev.