The "More stats" link under the Results -> Analysis tab seems to have some kind of loop in it. After creating a form with a number component, and after submitting it once, this link results in the following error:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 35 bytes) in /Users/nate/Sites/webform.com/www/sites/all/modules/contrib/webform/components/number.inc on line 444
CommentFileSizeAuthor
#1 webform_number_infinite_loop.patch2.81 KBquicksketch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Status: Active » Needs review
FileSize
2.81 KB

Clarifying the problem, this actually only occurs when you have already made submissions but left the fields blank. This results in the total value being "0", thus causing the standard deviation loop to add up a series of values that it assumes will be more than 0. In the event that all the submissions are blank (or 0), the standard deviation code gets stuck in a loop and PHP runs out of memory adding up a really, really big number.

This patch corrects the problem by making sure the $sum variable is greater than 0 before doing the computation. While fixing all the problems with zeros, I also found that decimals aren't handled quite right. We've got a bunch of checks for if ($component['extra']['decimals'] != ''), but they're unnecessary since _webform_number_format() can handle the decimal value being an empty string (it triggers "automatic" length display, showing zero to four decimals if needed).

quicksketch’s picture

Status: Needs review » Fixed

Committed to both branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.