--- /home/kratib/projects/drupal-4.7.3/modules/poll.module 2006-04-14 11:05:20.000000000 +0200 +++ poll.module 2006-10-13 00:47:46.000000000 +0200 @@ -479,15 +479,19 @@ function poll_view(&$node, $teaser = FAL function poll_update($node) { db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid); - db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid); + db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid); + $total_votes = 0; foreach ($node->choice as $choice) { - $chvotes = (int)$choice['chvotes']; + $chvotes = (int)$choice['chvotes']; + $total_votes += $chvotes; $chtext = $choice['chtext']; if ($chtext != '') { db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $chtext, $chvotes, $i++); } + } + if (0 == $total_votes) { + db_query('DELETE FROM {poll_votes} WHERE nid = %d', $node->nid); } }