Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#13 | use-local-db-2013859-13.patch | 18.54 KB | theneonlobster |
#12 | use-local-db-2013859-12.patch | 18.55 KB | theneonlobster |
#11 | use-local-db-2013859-11.patch | 18.87 KB | theneonlobster |
#7 | use-local-db-2013859-7.patch | 12.02 KB | theneonlobster |
#6 | use-local-db-2013859-6.patch | 11.7 KB | bryanhirsch |
Comments
Comment #1
bryanhirsch CreditAttribution: bryanhirsch commentedI'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.
Comment #2
tknospdr CreditAttribution: tknospdr commentedI 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
Comment #3
bryanhirsch CreditAttribution: bryanhirsch commentedPlease 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
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks, @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.
Comment #5
Vali Hutchison CreditAttribution: Vali Hutchison commentedI'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.
Comment #6
bryanhirsch CreditAttribution: bryanhirsch commented@kevee, sounds good. Thanks for checking.
@SlackerD, good catch. Thanks! Included array_filter() in cache_set and cache_get in attached reroll of patch.
Comment #7
theneonlobster CreditAttribution: theneonlobster commentedThe 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.
Comment #8
bryanhirsch CreditAttribution: bryanhirsch commented@theneonlobster, awesome. Thanks.
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedI 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.
Comment #10
bryanhirsch CreditAttribution: bryanhirsch commented@kevee, sure. With these changes committed my cart is officially hitched to the textcaptcha wagon. Happy to help maintain it.
Comment #11
theneonlobster CreditAttribution: theneonlobster commentedThe 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.
Comment #12
theneonlobster CreditAttribution: theneonlobster commentedThe last patch included an element from a different issue. The attached patch resolves that.
Comment #13
theneonlobster CreditAttribution: theneonlobster commentedMissed a typo. One last patch.
Comment #14
bryanhirsch CreditAttribution: bryanhirsch commented