Download & Extend

Anonymous users weird behaviour when limit is reached, no submit error is given, record not saved

Project:Webform
Version:6.x-3.4
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

This just looks like some code that needs cleaning up.

webform.module line 1832 of function webform_client_form_validate calls theme_webform_view_messages but that function never returns any variable

So the end result is form_set_error is called which stops the form submitting but the user never knows why.

    if (!$finished && $limit_exceeded = _webform_submission_limit_check($node)  ) {
      $error = theme('webform_view_messages', $node, 0, 1, 0, $limit_exceeded, array_keys(user_roles()));
      form_set_error('', $error);
      return;
    }

Comments

#1

That sounds unusual. Are you sure you haven't overridden theme_webform_view_messages() in your template.php file? Could you provide steps to reproduce?

#2

Status:active» needs review

So the problem here is that when the page cache is enabled, the messages aren't shown. It seems that theme_'webform_view_messages() is taking into account if the page is cached on submit, when it really should only take that into account when viewing the webform as an anonymous user. In other words, Webform is incorrectly caching when submitting a form, which causes message to not be shown.

This patch changes theme_webform_view_messages() to take an additional argument for $cached, so that it can respond appropriately depending on the situation.

AttachmentSize
webform_messages_cached6.patch 2.43 KB

#3

Similar patch for Drupal 7.

AttachmentSize
webform_messages_cached7.patch 2.54 KB

#4

But the code still calls theme_webform_view_messages which does not return any text..

$error = theme('webform_view_messages', $node, 0, 1, 0, $limit_exceeded, array_keys(user_roles()));
form_set_error('', $error);

#5

It should now return text, but only when you try to submit the form as an anonymous user. It should not return anything when you view the form as an anonymous user (for the reasons noted in the PHPdoc).

#6

#7

No does not fix the issue, are you testing this also?

- Anonymous users, seems to ONLY accept ONE submission from any anonymous user, is it limiting it by IP Address?

- No message is displayed at the top of the form saying that they have already submitted this form for anonymous module

#8

No does not fix the issue, are you testing this also?

Yes.

- Anonymous users, seems to ONLY accept ONE submission from any anonymous user, is it limiting it by IP Address?

Yes, see my response in #965424: Anonymous users cant submit, no warning given ontop of form

- No message is displayed at the top of the form saying that they have already submitted this form for anonymous module

A message will not be displayed at the top of the form as I explained in #5, and as documented in the patch:

+ * @param $cached
+ *   Whether the page contents are being cached. Messages that are user-specific
+ *   should not be shown when the page is cached, otherwise the message may be
+ *   shown to other users. Some messages should always be shown even if the page
+ *   is cached, such as "Submissions for this form are closed", because they
+ *   apply to all users equally.

#9

Okay I looked at this issue again today. Sorry dgtlmoon, I don't know what I was thinking. I see what you're saying now. You're right that no message is ever returned by theme_webform_view_messages(), it makes the assumption that the theme function will print out a message if the message cannot be sent. The call to form_set_error('', $error); is just to ensure that the processing of the form stops.

That section of code is only called if $limit_exceeded is set to TRUE, in which case theme_webform_view_messages() should output something like 'You have submitted this form the maximum number of times (@count).'. Despite the fact that I wasn't understanding what you were saying, the current patches should still fix the problem. I'm re-rolling these now to clean up the section of code that is so confusing, with the empty $message variable that isn't actually returned.

#10

Status:needs review» fixed

I've committed these patches which should fix the following:

- Messages should now be shown to anonymous users if they have exceeded the submission limit, but only when they attempt to submit the form (not just when viewing it).
- The "You need to login" message is now shown again to anonymous users if needed.
- Pressflow/D7 caching mechanisms are now checked more accurately.

AttachmentSize
webform_messages_cached-d6.patch 4.79 KB
webform_messages_cached-d7.patch 4.85 KB

#11

Status:fixed» closed (fixed)

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

#12

   if ($page && isset($message)) {
-    drupal_set_message($message, $type, FALSE);
+    drupal_set_message($message, $type);
   }

Was this change intentional? It rolled back #1009262: "You have already submitted this form" message repeats sometimes which you committed a few days before this. I'll reopen that issue too, but just thought I'd leave a note here.

nobody click here