Index: poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.231
diff -u -r1.231 poll.module
--- poll.module	4 Jun 2007 07:22:21 -0000	1.231
+++ poll.module	7 Jun 2007 09:48:49 -0000
@@ -234,6 +234,7 @@
 
   db_query("INSERT INTO {poll} (nid, runtime, active) VALUES (%d, %d, %d)", $node->nid, $node->runtime, $node->active);
 
+  $i = 0;
   foreach ($node->choice as $choice) {
     if ($choice['chtext'] != '') {
       db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $choice['chtext'], $choice['chvotes'], $i++);
@@ -372,7 +373,7 @@
 /**
  * Generates the voting form for a poll.
  */
-function poll_view_voting($node, $block) {
+function poll_view_voting(&$form_state, $node, $block) {
   if ($node->choice) {
     $list = array();
     foreach ($node->choice as $i => $choice) {
@@ -395,7 +396,7 @@
  * Themes the voting form for a poll.
  */
 function theme_poll_view_voting($form) {
-  $output .= '<div class="poll">';
+  $output  = '<div class="poll">';
   $output .= '  <div class="vote-form">';
   $output .= '    <div class="choices">';
   $output .= drupal_render($form['choice']);
@@ -522,9 +523,7 @@
   $nid = arg(1);
 
   if ($node = node_load($nid)) {
-    $edit = $_POST;
-    $choice = $edit['choice'];
-    $vote = $_POST['vote'];
+    $choice = $_POST['choice'];
 
     if (isset($choice) && isset($node->choice[$choice])) {
       if ($node->allowvotes) {
@@ -562,11 +561,10 @@
 /**
  * Callback for canceling a vote
  */
-function poll_cancel(&$node) {
+function poll_cancel($node) {
   global $user;
 
-  $nid = arg(2);
-  if ($node = node_load($nid)) {
+  if ($node = (is_object($node) ? $node : node_load($node))) {
     if ($node->type == 'poll' && $node->allowvotes == FALSE) {
       if ($user->uid) {
         db_query('DELETE FROM {poll_votes} WHERE nid = %d and uid = %d', $node->nid, $user->uid);
@@ -584,7 +582,7 @@
     else {
       drupal_set_message(t("You are not allowed to cancel an invalid poll choice."), 'error');
     }
-    drupal_goto('node/'. $nid);
+    drupal_goto('node/'. $node->nid);
   }
   else {
     drupal_not_found();
@@ -617,7 +615,7 @@
   }
 
   if (!empty($node->allowvotes) && ($block || arg(2) != 'results')) {
-    if ($_POST['op'] == t('Vote')) {
+    if (isset($_POST['op']) && $_POST['op'] == t('Vote')) {
       poll_vote($node);
     }
     $node->content['body'] = array(
