Hi,

i have a problem with your views_cloud Modul Vers. 6.x-1.1 ... can you help me..?

My System Environment

Shared Hosting
Drupal: 6.15
MySQL database: 5.0.81
PHP: 5.2.12
PHP register globals: Disabled

Problem:

Error: Division by zero in /homepages/d615/sites/all/modules/views_cloud/views_cloud.module on line 152.

Code:

if ($algorithm == 'linear') {
$range = ($sizes - 1) / ($max - $min);
$value = ($value - $min) * $range;
return (intval($value + 1));
}
else {
$value = log($value == 0 ? ++$value : $value);
$min = log($min == 0 ? ++$min : $min);
$max = log($max);
$range = ($sizes - 1) / ($max - $min); // here is the problem => this is the Line 152
$value = ($value - $min) * $range;
return (intval($value + 1));
}

PS: I have the other 2 patches from the issues queue integrated but my error is dont go away....

Thank you for your Help & for your Mdule.

Best Regards from Munich
Attila

Comments

quicksketch’s picture

Status: Active » Closed (fixed)

This problem should be impossible to encounter after #507376: Support for logarithmic mapping was included. Assuming this is the line that you get division by zero on:

$range = ($sizes - 1) / ($max - $min);

It should now never be executed because just a few lines above it there is a check to prevent division by zero:

if ($min == $max) return 1;

Since there haven't been any confirming reports, I'm assuming that this has already been corrected. Try using the latest stable version of the module.

henrijs.seso’s picture

Title: Division by zero in views_cloud.module on line 152 » Division by zero
Status: Closed (fixed) » Active

Still a problem in latest stable, looks like check is ineffective because after log() both $min and $max is 0. Needs patch.

quicksketch’s picture

because after log() both $min and $max is 0.

How is that not solved already by this conditional?

if ($min == $max) return 1;

If $min and $max are both 0, you'll never get to the division at all.

henrijs.seso’s picture

they are not 0 before log(). Sorry I cannot explain more, but dsm() told me that before one was 1 and other was 0, so they are not equal and after log() they both are 0. Im not that good with math and php :)

mthiner’s picture

I'm experiencing the same error (Error: Division by zero in .../sites/all/modules/views_cloud/views_cloud.module). I have the most recent release. Please advise.