Apache hangs on frontpage with >2 options in decision

fajerstarter - September 29, 2006 - 13:58
Project:Decisions
Version:HEAD
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

This is what I've found out so far:

Create a decision - poll or runoff. Let it have more than 2 options. Go to the frontpage (/node). Now Apache hangs, and Windows prompts a regular program error report (or what it's called).

This only happens when going to the frontpage, it's still possible to view the node on it's own view page. If you delete the node or change it to have 2 or less options the problem goes away.

Once I got this error from Drupal: "warning: array_filter(): An error occurred while invoking the filter callback in W:\www\drupal-4.7.3\includes\form.inc on line 42.".

Using a new installation of Drupal 4.7.3, VotingAPI and Decision module.

#1

ChrisKennedy - October 5, 2006 - 05:52

Hmmm, my initial impression is that this is not a problem with Decisions. What versions of PHP, Apache, and MySQL are you using? My own test installation (which is always updated to CVS) works fine in the given situation. Are there any log messages or additional information that might shed light on the issue?

#2

fajerstarter - October 5, 2006 - 13:26

Hmmm, my initial impression is that this is not a problem with Decisions.

That was also my first thought, but the fact that removing/adding a decision with >2 options correlated exactly with my server hanging made me think otherwise and I haven't experienced the problem before.

I'm running Apache/2.0.54 (Win32) PHP/4.3.11 MySQL 4.1 (local testenvironment). Drupal 4.7.3, at that time the latest decisions module and VotingAPI for 4.7. Fresh installation.

I looked through the Apache logs files but couldn't find anything.

I'll do some additional testing.

#3

fajerstarter - October 5, 2006 - 19:45

Updated my test environment to Drupal 4.7-cvs without any luck. I guess this thing will be hard to track if I'm the only one seeing the error, but I give it my last shot anyway.

I'll tracked down the code below, not suprisingly, to initiate the error. I have no idea if the bug is in the decision code or anything else, but this is what firing it:

line 34:

foreach ($node->option as $key => $option) {
$list[$i] = check_plain($option);

      $form['option']['Option_' . $key] = array(
        '#type' => 'checkbox',
        '#title' => check_plain($option),
        '#required' => FALSE,
        '#weight' => $weight++,

the specific code seems to be on line 37:
$form['option']['Option_' . $key] = array(

if I change line 37 to this, the error goes away (but the form gets messed up):
$form['Option_' . $key] = array(

#4

fajerstarter - October 5, 2006 - 19:49

Also, another thing:

If you do the normal thing to initiate the error (create decision >2 options, got to frontpage) it can also be "solved" by either posting a new decision AND voting on it, posting a decision with only 2 options or posting a poll content typ from poll.module. Looks like putting a node with a form "above" the buggy node have a positive effect.

My non-programmer guess would be that the code I pointed to creates some kind of infinite loop.. how sound that?

Also the error I mentioned before again appeared a couple of times:
array_filter(): An error occurred while invoking the filter callback in W:\www\drupal-4.7.3-plain\includes\form.inc on line 42.

#5

fajerstarter - October 10, 2006 - 18:34

Installed Decision CVS, Drupal 4.7-cvs and VotingAPI 4.7 on a new local testsystem (XAMPP on WindowsXP running PHP 4.3.10 and MySQL 4.1.10).

On this setup I don't see the windows program error window (i.e. Apache keeps running) and the threshold are 4 instead of 3 choices. Instead there are some errors showing:

This error is shown when posting a decision with 4 choices:
warning: array_filter(): An error occurred while invoking the filter callback in H:\xampp\htdocs\drupal-4.7\includes\form.inc on line 42.

This error is shown when posting a decision with 5 choices:
warning: array_filter(): An error occurred while invoking the filter callback in H:\xampp\htdocs\drupal-4.7\includes\form.inc on line 42.
warning: implode(): Bad arguments. in H:\xampp\htdocs\drupal-4.7\includes\form.inc on line 303.
warning: implode(): Bad arguments. in H:\xampp\htdocs\drupal-4.7\includes\form.inc on line 303.
warning: implode(): Bad arguments. in H:\xampp\htdocs\drupal-4.7\includes\form.inc on line 303.
warning: implode(): Bad arguments. in H:\xampp\htdocs\drupal-4.7\includes\form.inc on line 303.

I couldn't test with more than 5 choices, see this issue.

#6

ChrisKennedy - October 11, 2006 - 06:05
Status:active» needs review

Okay I finally got a chance to look into this - the attached patch should fix it. I couldn't reproduce the crash but my test environment uses PHP 5.0 and it appears that this is a bug in PHP 4 in which php doesn't initialiaze multi-key arrays properly.

AttachmentSize
decisions_arrayfilter_crash.patch 1.53 KB

#7

fajerstarter - October 11, 2006 - 06:53

Applied the patch but unfortunately still the same behaviour on both my servers (see above).

#8

fajerstarter - October 17, 2006 - 14:41

I'm really proud of this one :) Reading from http://api.drupal.org/api/HEAD/file/developer/topics/forms_api_reference... this seems to be the correct way of dealing with many checkboxes. I had another way of fixing this issue but this seems to the cleanest one.

I haven't done anytning to ranking.inc in this patch, but I think that it can be solved by using #tree, http://api.drupal.org/api/HEAD/file/developer/topics/forms_api_reference..., or by replacing ['choice']['Choice_' . $key] with only ['Choice_' . $key]. That was how I first fixed poll.inc (before I read the Forms API Reference...)

AttachmentSize
poll.inc_apache.patch 2.01 KB

#9

ChrisKennedy - October 17, 2006 - 22:33
Status:needs review» reviewed & tested by the community

Looks good to me - I commited it and used #tree for ranking.inc. http://drupal.org/cvs?commit=42960

Does it fix the crash though?

#10

fajerstarter - October 18, 2006 - 06:11

No, ranking still initiates the error. I've found a workaround though, it's not pretty but it seems to work. It sets the #type to "checkboxes". "Fieldset" would be more appropriate but it doesn't fix the error. In the attached patch I also removed some unnecessary properties.

As mentioned in #8, if we feel that this is to ugly, we could instead create a "flat" list of choices, maybe that would be the cleanest solution?

Or do we have enough info on this to file a bug against formAPI? - I'm still not 100% convinced that formAPI supports what we are trying to do, so is it really a bug..?

AttachmentSize
rank.inc_apache.patch 860 bytes

#11

fajerstarter - October 18, 2006 - 06:11
Status:reviewed & tested by the community» needs review

#12

ChrisKennedy - October 18, 2006 - 22:52
Status:needs review» fixed

Looks good to me, thanks for all the work and testing. http://drupal.org/cvs?commit=43073

#13

Anonymous - November 1, 2006 - 23:01
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.