I've created and configured a web form in such a way that only registered users are allowed to submit.

While testing this configuration (by trying to submit anonymously) I received the following warning message:

warning: Invalid argument supplied for foreach() in /home/content/n/o/j/admin/html/drupal/modules/webform/webform.module on line 2225.

Looks like a bug to me.

Please look into this.
Thank you!

Comments

hop’s picture

Title: User with no permission to submit a web form gets an unexpected error message while trying to submit. » Unexpected error message while trying to submit.
Component: Miscellaneous » Code
Assigned: Unassigned » hop

I see this bug only when I enable choice "Limit the number of submissions a user may send within a specified time period".
Choice "Unlimited" is OK.

TimK’s picture

I see a similar issue using Webform 5.x-2.6, probably the same issue.

It turned out to be a caching issue. When I turn off page caching for anonymous users, it works fine. For my application, this will serve as a suitable workaround. If you need a more elaborate workaround, you might try using CacheExclude to disable caching each Webform node page.

The root of the problem appears to be as follows:

  1. When the anonymous user first views the form page, the form is displayed.
  2. After he then submits the form and returns to the form page, Drupal displays the cached version of the page, which redisplays the form. (Rather, Webform wants to display a message, "You have already submitted this form," with no form actually displayed, because the user already submitted it.)
  3. When the user then resubmits the already-submitted form, Webform gets confused (although I don't quite understand how or why).

-TimK

kardave’s picture

Version: 6.x-2.6 » 6.x-2.9

subscribing
(it is still bug in 2.9.)

quicksketch’s picture

Status: Active » Needs work
StatusFileSize
new2.17 KB

I've fixed this issue in the 3.x version, which had a similar problem with the submit limit and the page cache. Porting this patch back to 2.x should possible fairly easily.

quicksketch’s picture

Status: Needs work » Patch (to be ported)
quicksketch’s picture

Title: Unexpected error message while trying to submit. » Page cache interferes with submit limit for anonymous users
Scott Reynolds’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new2.02 KB

and here is a patch.

Scott Reynolds’s picture

StatusFileSize
new2.22 KB

didn't realize i had an old version. heres a reroll, even though previous patch should apply.

quicksketch’s picture

Status: Needs review » Fixed

Thanks Scott Reynolds, everything looked good except the path to the webform_submissions.inc file was off for the 2.x branch location. Committed to Drupal 5 and 6 branches.

Status: Fixed » Closed (fixed)

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