[geeklog-devel] Bug in admin/poll.php
Tom Willett
tomw at pigstye.net
Mon Jan 13 16:56:27 EST 2003
I discovered a bug in admin/poll.php and a fix sort of.
If your config.php has maxanswers set to 10 the poll editor will list 11
answers. You can fill all 11 in and they will be saved properly, and
processed properly, however if you go back to edit them only the first l0
are display with the 10th answer also displayed in the 11th position. If
you save it then the 11th answer is overwritten with the 10th.
The problem is with the carry over of the listitem.thtml. It starts off
with one item in the list and everytime through the loop you do the parse
which adds another item to the list. So that the final time through the
loop it saves the 10th item to the list and creates another item the 11th.
The fix is to not parse the final item in the list.
This presents one difficulity. If you already have a poll with 11 items in
it you will loose the last item. With that in mind here is fixed code:
on admin/poll.php v 1.27 line 245 you have the following loop:
for ($i = 0; $i < $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
$poll_templates->parse('answer_option','answer',true);
}
Replace it with this loop:
for ($i = 1; $i <= $_CONF['maxanswers']; $i++) {
$A = DB_fetchArray($answers);
$poll_templates->set_var('answer_text', htmlentities ($A['answer']));
$poll_templates->set_var('answer_votes', $A['votes']);
if ($i < $_CONF['maxanswers']) {
$poll_templates->parse('answer_option','answer',true);
}
}
--
Tom Willett
tomw at pigstye.net
More information about the geeklog-devel
mailing list