Hello,

I've already read a lot of threads related to this issue but none solved my problem.

I am currently having an issue with image_captcha in that the captcha image is not being displayed for any form when the user is anonymous. When I log in, I can see the captcha image correctly.
Also, this issue only happens on the production server. Localhost is ok for both admin and anonymous users.

I did try to do the following:
* I verified that GD is working and the fonts are working (they have to be since an image is created when a user logs in, and on the captcha admin page (i.e. the 10 examples page)).
* Using Firebug NET panel, I see a 0x0 image being loaded. I get a 200 request, so apart from the 0x0 px, the request seens to be ok.
* I switched the captcha type to math to see if it would work, and it worked correctly when the user is anonymous.
* I viewed the page source for the form as an anonymous user, and I could see the tag for the captcha image.
* I tried switching the drupal caching from normal to disabled, and no changes.
* I checked my users table and there is a row for user id=0.
* I checked my sessions table and there are several rows for user id 0.

What it's weird:
* Although the image is generated correctly in the Captcha admin Example pages (admin/user/captcha/captcha/examples and admin/user/captcha/captcha/examples/image_captcha/Image) and in the Example fieldset of the ImageCaptcha admin page (admin/user/captcha/image_captcha), the images of the "Font settings" fieldset on the ImageCaptcha admin page are not being displayed for auth user. They are broken just the way the captcha is broken for anonuymous users.
* In the production server I had to add a "ob_clean();" on the line 26 of "image_captcha.user.inc" to make the captcha image be rendered in the admin pages. It seems that one of the site files is outputing a trash-character (maybe encoding problem), but it doesn't happen in my localhost. I've already uploaded all files to production again, but the problem persists.

Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

soxofaan’s picture

Category: bug » support

Hi,

Thanks for such an elaborate report, this saves us a lot of time and back and forth posting.

Anyway: if you say ".. math captcha worked correctly when the user is anonymous.", do you mean that the challenge just shows up for anonymous visitors, or did you also test that submitting the form was correctly blocked with a wrong CAPTCHA response and correctly allowed with a correct CAPTCHA response?

Are there any relevant error/warning messages in the Drupal watchdog log or your server logs?

Is this production site publicly accessible? Can you disclose an URL so I can have a look?

matheusgorino’s picture

Hi Soxofaan,
The website is not publicly accessible, it hasn't been launched yet.
Yes, Math Captcha works and there's no error messages on Drupal or server logs =/
But I have a new information:
- I have uploaded a local database backup to the production server and then captcha started to work for anonymous users.
- Then I restored the production database again and it stopped work.
So there's something with the database. I've just cleared all the caches, sessions and captcha_sessions tables, but it didn't resolved my problem.
I can't get rid of the production database because the client have already entered a lot of information =/
Thank you.

soxofaan’s picture

Is completely uninstalling and reinstalling the captcha module an option?

matheusgorino’s picture

Just did and it still doesn't work :(

soxofaan’s picture

(Sorry for the delay, my time for drupal support is limited)

Do you have a lot of modules enabled on your site?

qasimzee’s picture

I am having the exact same bug. Is there any fix? Watch dog shown:

CAPTCHA problem: unexpected result from hook_captcha() of module image_captcha when trying to retrieve challenge type sites for form captcha_examples.

vomitHatSteve’s picture

Subscribing:

I have had a very similar problem with captcha/image_captcha 6.x-2.4, but I believe I was not having the problem with 6.x-2.3. (The problem wasn't noticed until a client pointed it out. Whoops!)

The titular image_captcha image captchas were not loading. If you tried to view it directly in firefox, it would generate an image saying:

The image "http://example.com/image_captcha/12/3456789012" cannot be displayed because it contains errors

Adding an ob_clean() call before line 26 of image_captcha/image_captcha.user.inc (as the OP suggested) seems to resolve the issue.

soxofaan’s picture

Status: Active » Needs review
FileSize
873 bytes

@vomitHatSteve: There didn't change much in the image captcha between 6.x-2.3 and 6.x-2.4, so I don't think the upgrade is the culprit in you case. More likely an update or addition to another modules that fills the output buffer for some reason.

Anyway, here is a patch to add an ob_clean(), based on Drupal core's file.inc

Status: Needs review » Needs work

The last submitted patch, 976436-clean-ob-image-captcha-01.patch, failed testing.

soxofaan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 976436-clean-ob-image-captcha-01.patch, failed testing.

shadowmihai’s picture

subscribe.

Same thing in drupal 7 with 7-x-1.0-alpha2. It was working fine, then stopped showing up. No error messages, and it appears that the system is generating the image, but it disappears. Also - and I think this must be important somehow - the "sample fonts" are not displayed in the configuration page - but the directory is listed in place of the font images. They stopped showing up at the same time.

wundo’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 976436-clean-ob-image-captcha-01.patch, failed testing.

wundo’s picture

Status: Needs work » Fixed

Although it failed the testing it seems good for me, committed.

soxofaan’s picture

Version: 6.x-2.3 » 7.x-1.x-dev

thanks
I also "git cherrypicked" it to the 7.x-1.x branch (master)

Status: Fixed » Closed (fixed)

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

cristian100’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2
Status: Closed (fixed) » Active

I have this very same issue with Image Captcha, in some forms it works, and at some others it doesn't:

Look at this, at the form at the right sidebar:
http://www.buscarsalud.com/perfil/cristian-antonio-gonzalez-cienfuegos-2...

soxofaan’s picture

Look at this, at the form at the right sidebar:
http://www.buscarsalud.com/perfil/cristian-antonio-gonzalez-cienfuegos-2...

looks normal to me (see attached screenshot).

What is the problem you are seeing?

lhugg’s picture

Version: 7.x-1.0-beta2 » 7.x-1.0
FileSize
5.6 KB

This issue is still happening. Using Image CAPTCHA, the image would paint and then vanish in a split second. This happens on all our sites that upgraded to 7.x-1.0 from one of the betas, usually beta 2.
I'm still trying things, but it seems at this point to happen when you add 'noise' to the image. As I find more I'll update this.
But this would be good for the maintainers to look into.
Thanks.

soxofaan’s picture

Status: Active » Postponed (maintainer needs more info)

If you have this issue, please provide enough info: which browsers? which version of drupal? which other modules do you have installed? is there a publicly accessible url to test it? what happens when you do download/"open image in new tab" (or whatever your browser provides)?

without this kind of info there is not much the maintainers can do

michaelkoehne’s picture

Kaspersky + Chrome. Shut down Kaspersky and try again, or try in another browser.

Stephen Ollman’s picture

I had the same issue suddenly happen to me after an update to 6.x-2.5.

I made the mistake of logging out so could not get back in to the site as admin.

So, if you cannot login because of Captcha do the following:

(If you are logged in then skip to step 4)

1. Access database tables (I used phpMyAdmin)
2. Run the following SQL query:
SELECT * FROM `system`WHERE filename LIKE '%captcha%'
3. Edit the /captcha/captcha.module and /captcha/image_captcha/image_captcha.module entries and change the status values to '0'
You should now be able to login again as Captcha is now disabled.
4. Go to: /admin/user/captcha/image_captcha and select a font in the font setting fieldset. (for some reason mine had unchecked after the module update).
5. Save and you're good to go. (test in another browser that Captcha now appears)

Hope this helps someone.

Chris Matthews’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

I'm closing this 5 year old support request as cannot reproduce.