I'm using Drupal 6.6 and CAPTCHA module version 6.x-1.0-rc2. I have added a reCAPTCHA to the creation form for one of my custom content types. I've also changed the reCAPTCHA theme settings to use the "clean" theme rather than the default "red" (though the bug also appears if the reCAPTCHA theme is set to "white" or "black glass" as well; I have not tried to use a custom theme).
When I try to submit the form, if I do not type in the correct value for the reCAPTCHA challenge, the reCAPTCHA theme reverts back to the default "red" rather than retaining the reCAPTCHA theme I have selected. This occurs because the javascript to set the RecaptchaOptions value does not get output.
This bug occurs whether the reCAPTCHA is setup to use a secure connection or not. It also occurs regardless of the CAPTCHA persistence setting.
Comment | File | Size | Author |
---|---|---|---|
#5 | recaptcha.module.patch | 3.11 KB | igwk |
#4 | recaptcha.module.patch | 3.27 KB | igwk |
#3 | recaptcha.module.patch | 3.15 KB | igwk |
Comments
Comment #1
igwk CreditAttribution: igwk commentedOh and in case it matters, I should also mention that I'm using the default Garland theme for the site itself.
In addition, I just discovered that this behavior does NOT occur when I use the reCAPTCHA with the built-in forms like comment_form and contact_mail_page so it only appears to affect custom content types. I'm using CCK version 6.x-2.0.
Comment #2
igwk CreditAttribution: igwk commentedI don't know much of anything about PHP programming (and certainly nothing about the Drupal API), but I tried looking into this further and I added a bunch of error_log() calls to recaptcha.module to see what I could figure out. On the case where I was seeing the theme switch itself back to the default 'red' theme, the recaptcha_captcha function was only getting called once for the "preprocess" case, whereas the case where the theme stays clean (e.g. with a recaptcha on the "contact us" form), the recaptcha_captcha function gets called twice: once for the "generate" case, and once immediately afterwards for the "preprocess" case.
Since the javascript code to specify the recaptcha theme is only output from the "generate" case, the buggy condition arises from the "generate" case not being called before the "preprocess" case.
At this point, I'm sure whether the recaptcha module is buggy because the preprocess case doesn't try to output the theme javascript code, or whether the captcha module is buggy because it doesn't always call the "generate" case before the "preprocess" case. The captcha module documentation doesn't seem to make any guarantees that the "generate" case should always be called before the "preprocess" case so I'm thinking this is a recaptcha bug. Does anyone else with a better understanding of how this should all work with respect to the captcha module integration have an idea of how to best go about fixing this issue?
Comment #3
igwk CreditAttribution: igwk commentedHere's a patch that generates the javascript code to set the reCAPTCHA theme for both the "generate" and "preprocess" states.
Comment #4
igwk CreditAttribution: igwk commentedHere's an updated patch for the reCAPTCHA 6.x-1.1 release.
This also fixes another buggy case where the reCAPTCHA theme would be reset. The particular situation occurred when the user would enter the correct reCAPTCHA response, but would fail to successfully submit the form (e.g. because one of the other required fields was missing).
Comment #5
igwk CreditAttribution: igwk commentedOoops, had an extra print call in the previous patch. Here's a version of the patch without the print.
Comment #6
hass CreditAttribution: hass commentedBump for robot.
Comment #7
hass CreditAttribution: hass commentedComment #8
hass CreditAttribution: hass commentedComment #12
hass CreditAttribution: hass commentedClosing because of inactivity.