We noticed that the "Need more choices" box wasn't working when creating a poll. After looking into it, it seemed that $form_values at line 129 of poll.module wasn't behaving as expected.

My current work-around is to change:

  if (isset($form_values)) {
    $choices = $form_values['choices'];
    if ($form_values['morechoices']) {
      $choices *= 2;
    }
  }

to:

  if (isset($_POST['choices'])) {
    $choices = $_POST['choices'];
    if ($_POST['morechoices']) {
      $choices *= 2;
    }
  }

-Nate

Comments

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

This sounds quite interesting. The hook_form() for Drupal 5 docs are a bit vague on what might be passed on the second parameter, but node_form() calls hook_form() actually, and it does this:

/**                                                                                                    
 * Generate the node add/edit form array.                                                              
 */                                                                                                    
function node_form($node, $form_values = NULL) {      
  // ...
  if ($extra = node_invoke($node, 'form', $form_values)) {                                             
    $form = array_merge_recursive($form, $extra);                                                      
  }

So it passes on the form_values it got from Drupal.

I tested this with both freshly submitted polls, in preview before submission, after submission and in preview as well as after voting and preview, and cannot reproduce.

nschindler’s picture

Version: 5.3 » 5.4

Yeah, I know... and the polls module is the only place I have this problem.

I recently upgraded to 5.4, so I reverted my work-around for this issue. It still misbehaved.
Here's the really weird part... I've had problems using mysqli vs. mysql before, so I switched to mysqli just to see if it had any effect. Nope. So I switched back to mysql, and now all of the sudden the original code (using $form_values) works.
I'm confused, but whatever. I think there's something quirky with my version of PHP.

Database interface - mysql
Database version - 5.0.26
PHP version - 5.1.2
Web Server - apache2-prefork-2.2.3
OS - SLES 10 SP1 2.6.16.53

gábor hojtsy’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Marking closed then.