PDA

View Full Version : What does this mean and what do we do about it?


pnhltt
12-19-2011, 06:32 PM
If one clicks "get the results of the poll" without voting then one gets such a notice:

Warning: Invalid argument supplied for foreach() in [path]/poll.php on line 688

What does it mean and what do we do to fix it?

Thank you.

kh99
12-19-2011, 06:43 PM
That looks like a bug to me. The code in poll.php looks like this (the foreach line is 688):


while ($name = $db->fetch_array($public))
{
$clc++;
fetch_musername($name);
$last[$name['voteoption']] = $clc;
$name['comma'] = $vbphrase['comma_space'];
$allnames[$name['voteoption']][$clc] = $name;
}
}

// Last elements
foreach ($last AS $voteoption => $value)
{
$allnames[$voteoption][$value]['comma'] = '';
}



and I believe it should look like this:

while ($name = $db->fetch_array($public))
{
$clc++;
fetch_musername($name);
$last[$name['voteoption']] = $clc;
$name['comma'] = $vbphrase['comma_space'];
$allnames[$name['voteoption']][$clc] = $name;
}

// Last elements
foreach ($last AS $voteoption => $value)
{
$allnames[$voteoption][$value]['comma'] = '';
}
}

pnhltt
12-19-2011, 08:07 PM
Are you suggesting we change first for the second?

PS.
:D It took me a while to see the difference, let alone understand why couple of brackets should cause any problems...

kh99
12-19-2011, 09:01 PM
Yes, I believe that will fix the issue. As you probably figured out, the only difference is that one closing bracket is moved down so that the foreach is inside.

pnhltt
12-19-2011, 11:07 PM
being stupid and cannot find how to do it and where...

kh99
12-19-2011, 11:12 PM
You'd need to edit poll.php. So download it from your server if you don't already have it on your local computer, then open it with a programming editor (like notepad++ - if you use wordpad or something like that it can cause problems). Next I would save a copy somewhere, then edit it and go to line 688. You should see code like is posted above. Make it look something like the second code (the indenting isn't important). Then upload it to your server, overwriting the one that's there. Then check if polls are working on your site, and if they aren't just upload the unedited copy you saved.

ETA: ...BTW, looks like it's a known bug that'll be fixed in the next version http://tracker.vbulletin.com/browse/VBIV-13614 .

pnhltt
12-23-2011, 10:23 PM
Did what was suggested, everything works. Thanks!