Relevant code snippet from captcha_validate() function:

  $captcha_info = $form_state['captcha_info'];

  // Get CAPTCHA session from CAPTCHA info
  // TODO: is this correct in all cases: see comment and code in previous revisions?
  $csid = $captcha_info['captcha_sid'];

  $solution = db_result(db_query('SELECT solution FROM {captcha_sessions} WHERE csid = %d', $csid));

I have a following scenario:
1. drupal form with image captcha.
2. There is a page that displays the form
3. form submitted using ajax request and form validate and submit callbacks always call exit()
4. attempts to submit such a form result in invalid captcha message form the very first attempt
5. debugging the problem leads me to think that captcha management in general is inconsistent.

Comments

soxofaan’s picture

Title: Captcha validation logic does not work for all cases » Support for AJAX/AHAH form workflows
Version: 6.x-2.3 » 6.x-2.x-dev
Category: bug » feature

The current implementation of CAPTCHA is known to be incompatible with AJAX/AHAH workflows
related issues:
#918856: CAPTCHA Session Reuse message on webforms
#180328: AHAH/AJAX request for new challenge
#334377: Patch to Allow AJAX Support

Maybe, it's a good idea to start the general discussion here in this thread.

The problem is that I have very limited time to work on this module and working with AJAX in Drupal 6, especially to get CAPTCHA working, is hairy to say at least

If you have any input on how to tackle this, please elaborate.

wundo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)