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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

igwk’s picture

Oh 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.

igwk’s picture

I 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?

igwk’s picture

Status: Active » Needs review
FileSize
3.15 KB

Here's a patch that generates the javascript code to set the reCAPTCHA theme for both the "generate" and "preprocess" states.

igwk’s picture

Version: 6.x-1.0 » 6.x-1.1
FileSize
3.27 KB

Here'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).

igwk’s picture

FileSize
3.11 KB

Ooops, had an extra print call in the previous patch. Here's a version of the patch without the print.

hass’s picture

Version: 6.x-1.1 » 6.x-1.x-dev
Issue summary: View changes

Bump for robot.

hass’s picture

Status: Needs review » Needs work
hass’s picture

Status: Needs work » Needs review

The last submitted patch, 3: recaptcha.module.patch, failed testing.

The last submitted patch, 4: recaptcha.module.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 5: recaptcha.module.patch, failed testing.

hass’s picture

Status: Needs work » Closed (won't fix)

Closing because of inactivity.