Hello, using latest drigg express way from 9th september (downloaded a couple of days ago) I've setup autovoting, but keep receiving this php error, division by zero:

Division by zero in /home/mydomainname.com/sites/all/modules/drigg/drigg_autovote/drigg_autovote.module on line 162.

Then in the next watchdog entry there is 0 votes:

Stories in queue voted by deciders: 0, Votes real: 0

Seconds since last autovoting: 172892, Voters deciders plus real: 0, Votes to assign per hour: 2, Votes per hour total: 0, Votes to assign: 0, remainder (votes): 0, reminder (seconds): (0 votes per seconds, 0 votes per minute), 172892 seconds passed since last autovoting

So I guess something is trying to divide by the number of deciders or real votes..

I have set up deciders and voters users, but I haven't voted with a decider user, so indeed there's no stories in queue voted by deciders, but there shouldn't be a php error of division by zero, the case should be handled by your script in a correct way.

Please tell me if you need more information about my setup or how to reproduce the bug.

Comments

mercmobily’s picture

Hi,

This autovoting thing _really_ is black magic. Even though the code has _no_ optimisation at all, it always takes me a _long_ time to figure it out...

In /home/mydomainname.com/sites/all/modules/drigg/drigg_autovote/drigg_autovote.module on line 162, please change:

    $remainder_in_seconds=$vote_remainder / $votes_per_second;

Into:

 if($votes_per_second == 0)
    $remainder_in_seconds=$vote_remainder / $votes_per_second;
  } else {
    $remainder_in_seconds=0;
  }

And let me know if it fixes the problem. If it does, I will commit it.

Bye!

Merc.

mercmobily’s picture

Hi,

Wooops... please watch out, the new code should be:

if($votes_per_second == 0){
    $remainder_in_seconds=$vote_remainder / $votes_per_second;
  } else {
    $remainder_in_seconds=0;
  }
davidmosen’s picture

Hi,

Hey Merc, I'm not familiar with that code, but I think it should be the other way round: you are dividing by it when it IS zero! ;)

David

mercmobily’s picture

Hi,

Oh geeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee!!!
Humm... err.. yah :-)

Merc.

mercmobily’s picture

Hi,

So...

if($votes_per_second == 0){
    $remainder_in_seconds=0;    
} else {
   $remainder_in_seconds=$vote_remainder / $votes_per_second;
}

Merc.

alliax’s picture

Hi, thank you for your patch, I've applied it and the php error has not reoccured after the cron update and before the "Stories in queue voted by deciders: 0, Votes real: 0" notification.

mercmobily’s picture

Hi,

OK. Can you please test it if it also works in "normal" conditions?

Merc.

alliax’s picture

I don't see what you mean by "normal" conditions. I've just installed Drigg, setup 50 false users, made 3 deciders and the rest voters, then I tested it by voting with a decider, it worked, the scoop has been promoted. And then after the php error occured.

Now after applying the patch there's no more php error. So your patch works in this matter.

But I have to admit that the exact way in which auto voting works is still quite foreign to me, I wish I could setup a system which would vote for stories in the upcoming queue at random without me having to hand select the scoops by logguing as a decider and voting for each one, but I guess you haven't done this scenario because you don't see the point in having a totally false digg, you just want an autovoting to help start a real digg. Well everyone's different. :-)

mercmobily’s picture

Status: Active » Fixed

Hi,

You are exactly right :-D

OK, fixed in CVS.

Merc.

wwwoliondorcom’s picture

Thanks for this one !

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

santhosh s r’s picture

Category: bug » support
Priority: Normal » Critical
Status: Closed (fixed) » Needs work

I am getting

Warning: Division by zero in C:\wamp\www\cleantype\wipreport.php on line 222

And in line 222 coding is

else
{
echo "

NIL

";
}

plz update anybody regarding these ASAP

santhosh s r’s picture

if($count3[$k]==0 AND $count2[$k]!=0)
{
echo "

In CSQ -->".$count2[$k]."

";
}
else if($count3[$k]!=0 AND $count2[$k]!=0)
{
echo "

In CSQ -->".$count2[$k]." and In QA -->".$count3[$k]."

";
}
else if($count3[$k]!=0 AND $count2[$k]==0)
{
echo "

In QA -->".$count3[$k]."

";
}
else
{
echo "

NIL

";
}

alliax’s picture

Status: Needs work » Fixed

Please santhosh s r find a loaded gun, look inside the barrel and press the trigger, your garbage has nothing to do with drupal or drigg. Not mentionning you don't have any division in your "code" :-)

Status: Fixed » Closed (fixed)

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