It seems to me that, since Hidden CAPTCHA just adds an input element, there is no reason to disable page caching when the CAPTCHA element is from the Hidden CAPTCHA module.
It would be great if we could override the CAPTCHA module's cache disabling in this case.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 2130615-diff-9-13.txt | 1.34 KB | vijaycs85 |
| #13 | 2130615-13.patch | 1.84 KB | vijaycs85 |
Comments
Comment #1
liam morlandIt might be possible to do this by calling
drupal_page_is_cacheable(TRUE)after thedrupal_page_is_cacheable(FALSE)happens in the captcha module. If that doesn't work, then it would require a change to the captcha module to make it so that add-on captcha modules, such as hidden_captcha, can disable the call todrupal_page_is_cacheable(FALSE). Patch welcome.Comment #2
fabianx commentedEnable cacheable captcha support (once 2449209 is committed):
I just implemented that for captcha, so the fix is really simple now.
A custom validation function is needed, because the solution is not actually available (and the random value inserted is returned instead), but as its the same empty response always, this works fine.
Comment #3
fabianx commentedThe simpler the patch, the more bugs crop in ...
=== should be used instead of == to ensure only really empty '' responses are counted.
Comment #4
fabianx commentedThe simpler the patch, the more bugs crop in ...
=== should be used instead of == to ensure only really empty '' responses are counted.
Comment #5
plachLooks good to me
Comment #6
liam morlandThe contents of hidden_captcha_captcha_validation() can be just:
return $response === '';I don't understand the reasoning for creating hidden_captcha_captcha_validation().
Comment #7
vijaycs85+1 to RTBC.
Minor code clean up suggestion:
Could be just one liner:
Comment #8
liam morlandComment #9
vijaycs85Sorry for duplicate comment @Liam Morland, clearly I didn't read #6. Here is the updated patch.
Comment #10
liam morlandI still don't understand the reasoning for creating hidden_captcha_captcha_validation(). This wasn't needed before, why now?
Comment #11
vijaycs85I think it's Form API to regenerate the hash, so that we cache the form without allowing to submit duplicate token.
Comment #12
liam morlandI don't understand. It should be explained in a comment.
Comment #13
vijaycs85Sorry, it wasn't clear comment. I tried to explain better in code comment in this page.
Just a note: We should get #2449209: Add support for cacheable captcha's (recaptcha) committing before this issue.
Comment #14
fabianx commentedThe reason why the new function is needed is because 'sid' is empty for cached pages, so a new sid is generated, but the default value for a new sid is a random token. Hence it would try to compare an empty input (correct) with a random token (incorrect).
Adding a new function for validation circumvents this as we are not depending on the state of the captcha (random token if sid is not set) at all.
Back to RTBC, but parent issue still needs to be committed first.
Comment #15
liam morlandPostponing until parent is committed.
Comment #16
miroslavbanov commentedParent is committed. Back to RTBC.
Comment #18
liam morlandThanks!
Comment #19
vijaycs85Thank you!