To recreate the bug:
- Enable block caching
- Create a webform with some mandatory fields, and generate a block of it
- Place the block in a region and make it visible everywhere (standard)
- Visit any page as an anonymous user (remember the page for later)
- Leave any of the mandatory fields blank and submit the form (which causes a form error)
- You will end up on the same page as you came from, so far so good
- Now go to another page and submit the form the same way you did before
- Now you'll end up on the first page, still showing the correct errors. You will from this point end up on that first page every time this webform causes an error (until you flush the cache), which of course is wrong.
Why?
Because the block is cached for anonymous users, so the action parameter is only rendered once, then brought from the cache. That means it doesn't change, but it should.
The blocks generated from webformblock are using BLOCK_CACHE_GLOBAL while they should be using BLOCK_NO_CACHE. (See hook_block)
Still doesn't work
It seems like Drupal doesn't care about this setting, or at least interprets it in a strange way, so unfortunately you have to disable block cache in order for the bug to disappear. However, it's still good to be correct, so please patch this anyways. I'll attach the patch here.
Some conclusion
I first thought that BLOCK_CACHE_PER_PAGE would be the correct one. In this case, it probably is. However, sometimes the webform's default values contains senitive user-specific information (like the IP-adress for instance), so it shouldn't cache at all i think... (Also see #486466: Anonymous users do not see updated versions of a webform when page caching is enabled)
However I would be happy to get any kind of feedback here! Thanks.
Comments
Comment #1
psynaptic commentedThis doesn't seem to have anything to do with block cache.
Comment #2
psynaptic commentedThis is fixed in DRUPAL-6--1. Please test!