Anonymous users shown empty webform without explanation

Created on 15 March 2017, over 7 years ago
Updated 1 June 2023, about 1 year ago

Create a new webform where the anonymous user has permission to submit. Set the "Total Submissions Limit" to be 1 ever. Visit the webform as the anonymous user and fill in. After submitting, if you revisit the webform, the webform title appears with no content and no messages are displayed. This occurs whether or not the page in question is cached.

The cause appears to be in the logic applied when trying to avoid invalidating the cache on a cached page.

In webform_node_view(), line 1949 checks whether the page is cacheable using drupal_page_is_cacheable(): if it is possible to cache the page, this function returns TRUE to a $cached variable whether or not the page actually is cached.

Line 1972 sets the $enabled variable to FALSE if the total webform submissions limit has been reached, ignoring the $cached variable. In theme_webform_view_messages, line 2152 checks whether the $cached variable is FALSE before setting the message to tell the user why the webform is disabled. This means that the anonymous user receives an empty webform and no message explaining why whether or not the page actually is cached.

This can be rectified by removing the check against the $cached variable before setting the message. However, as the total submission limit is a constant for all site visitors, this would mean the empty form could never be cached even though it won't change. It might make more sense to make the message about a form being disabled because the total submission limit has been reached part of the page content (and therefore cacheable) rather than a Drupal message (and hence not cacheable).

It might also be worth reconsidering the use of drupal_page_is_cacheable(), as this isn't a reliable method of identifying if a page actually is cached. As a minimum, any time the webform is disabled (and invisible) something should be shown to the user to explain why.

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024