Problem:
Forms are unusable when textcaptcha.com responds with a 404 (which happens frequently).

Solution:
Make requests to the API to cache challenge questions and answers on cron. Then use Drupal's own db to get questions and answers for forms.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bryanhirsch’s picture

I'm working on a proposed solution here:
https://github.com/bryanhirsch/textcaptcha

I'll post the patch when the solution is fully baked and ready for review. In the meanwhile, anyone who wants to help should feel free to ping me or fork this on github.

tknospdr’s picture

I have just installed textcaptcha and notice a similar issue. If I refresh a page that has the captcha on it 2 to 3 times per 10 refreshes I get no question, just the answer box.
You can see it in action by refreshing this page: http://www.floridapets.org/user/register

bryanhirsch’s picture

Please see attached patch.

This is also on github here:
https://github.com/bryanhirsch/textcaptcha

The patch is the difference between these two commits:
99477769b52a85c27621150e5b1f3e20a5731c72 <-- Tip of 7.x-1.x branch
a6c40f4a275276ceb2bc4b90ca237ad17bd648c2 <-- My most recent commit

Anonymous’s picture

Thanks, @bryanhirsch for this patch. While I agree that it's annoying to depend on a service that might go down, I think we should seek some input from Rob (feeder of textcaptcha) about how he feels about this approach. I couldn't find a hard-and-fast TOS for textcaptcha, but I think his input would be valuable. I'll reach out to him and see what he thinks.

Vali Hutchison’s picture

I've been testing the module today using the a6c40f4a275276ceb2bc4b90ca237ad17bd648c2 commit mentioned in https://drupal.org/node/2013859#comment-7508239

It works well, apart from about every 10 times I get the error "Sorry. Something went wrong. This CAPTCHA won't work. Please reload your page."

When this happens then the if ($cache = cache_get('textcaptcha_challenges')) on line 156 is run, but the value of $challenge is empty.

When i did print_r($cache); then my cache had some empty elements in the $cache->data array - so in the case of the error then the randomly selected array element is one of the empty ones.

To remedy this I have changed line 157 from:

$challenges =$cache->data;

to

$challenges = array_filter($cache->data);

which strips out the empty elements first before choosing a random one.

bryanhirsch’s picture

@kevee, sounds good. Thanks for checking.

@SlackerD, good catch. Thanks! Included array_filter() in cache_set and cache_get in attached reroll of patch.

theneonlobster’s picture

FileSize
12.02 KB

The patch in #6 didn't apply to the tip of 7.x-1.x; it was generated for the 7.x-1.2 release. I've generated a new patch for the same release, and this one includes an option to disable fetching questions on cron.

bryanhirsch’s picture

@theneonlobster, awesome. Thanks.

Anonymous’s picture

I just heard from the maintainer of textcaptcha that he's fine with this approach. I'm a bit busy right now, but if someone can change this to reviewed and tested I'll commit it.

Also, since it's always nice to have more committers, if Bryan would like to help maintain this module I'd appreciate it.

bryanhirsch’s picture

Status: Active » Reviewed & tested by the community

@kevee, sure. With these changes committed my cart is officially hitched to the textcaptcha wagon. Happy to help maintain it.

theneonlobster’s picture

The attached patch stores and manages challenge questions and answers locally in textcaptcha tables rather than the cache table. It also includes a drush command to fetch challenges, and a flag to disable fetching on cron.

theneonlobster’s picture

The last patch included an element from a different issue. The attached patch resolves that.

theneonlobster’s picture

Missed a typo. One last patch.

bryanhirsch’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.