When viewing "more stats" link on a number component in a webform with a single submission, I get the following out of memory error message due to an infinite loop:
Fatal error: Allowed memory size of 201326592 bytes exhausted (tried to allocate 20 bytes) in webform/components/number.inc on line 444

Comments

pdrake’s picture

Status:Active» Needs review
StatusFileSize
new689 bytes
new5.06 KB

This patch excludes the standard deviation table if the standard deviation is 0, which solves the infinite loop that causes the memory limit error. The second patch ("no_whitespace") was created by running git diff -w and is not intended to be used, but makes review much easier.

bxtaylor’s picture

Status:Needs review» Reviewed & tested by the community
StatusFileSize
new39.16 KB

I was able to reproduce the bug when only one submission exists. The patch applied cleanly and fixed the memory exhaustion issue.

From what I see, this prevents the distribution table from being printed if there's only one submission.

quicksketch’s picture

Thanks guys. If we're skipping the entire set of processing, could we short-circuit the function call and just use:

if (empty($stddev)) {
  return $rows;
}

I don't normally advocate multiple returns, but in this situation it avoids a lot of indentation and makes the code clearer. Acceptable?

bxtaylor’s picture

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new436 bytes

Works for me. Here's a reroll...

pdrake’s picture

Status:Needs review» Reviewed & tested by the community

I'm good with just short-circuiting here. It may be worthy of a comment to ensure nobody adds additional analysis rows after the stddev table rows?

pdrake’s picture

Status:Reviewed & tested by the community» Needs work

Conditional needs proper spacing.

bxtaylor’s picture

Status:Needs work» Needs review
StatusFileSize
new512 bytes

Rerolled with conditional spacing fix and comment.

pdrake’s picture

Status:Needs review» Reviewed & tested by the community

Works for me.

pdrake’s picture

Status:Reviewed & tested by the community» Needs review
StatusFileSize
new513 bytes

Ok, I noticed one more spacing problem. This patch resolves that.

bxtaylor’s picture

Status:Needs review» Reviewed & tested by the community

Ah yes...that space on the return line...

Looks good to me, now.

quicksketch’s picture

Status:Reviewed & tested by the community» Fixed

Thanks guys. Committed (finally)! Added to all 3.x and 4.x branches.

Status:Fixed» Closed (fixed)

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