Page MenuHomePhabricator

$wgCaptchaDirectoryLevels in FancyCaptcha seems broken when not zero
Closed, InvalidPublic

Description

I put my captcha images in a folder structure like:

/var/www/phptests/.fontres/a/image_0a487165_d1433be7373a6458.png
/var/www/phptests/.fontres/a/image_0b4a38c8_1c2c65d54cb68177.png
/var/www/phptests/.fontres/a/image_0ba57eab_6fed40aa0e103478.png
/var/www/phptests/.fontres/b/image_16252f86_e48dd4877918dacd.png
/var/www/phptests/.fontres/b/image_17441e00_447c609aa4c7430a.png
/var/www/phptests/.fontres/b/image_17810a2c_ccd70f8b5f08c9a0.png

And I have this in LocalSettings.php

$wgCaptchaDirectory = "/var/www/phptests/.fontres";
$wgCaptchaDirectoryLevels = 1;

However the captcha is blank when viewed in a browser.

I noticed in the browser console http://sodium:8080/mediawiki-1.35.0-rc.3/index.php?title=Special:Captcha/image&wpCaptchaId=1326427092 gets a 404 response.

When I use a simple folder structure with $wgCaptchaDirectoryLevels = 0; everything works.

Event Timeline

However the captcha is blank when viewed in a browser.

Are they correct if you view them via other means? Just to confirm they're being written correctly

Wikimedia uses $wgCaptchaDirectoryLevels = 3; but we do write the files to Swift rather than straight onto disk (though, we did write to NFS years ago)..

Are you asking about the image files themselves? Yes they seem to be valid captcha images. :)

Files on disk seem in the correct directories...

reedy@ubuntu64-web-esxi:/var/www/wiki/mediawiki/core/images/captcha$ tree
.
├── 0
│   └── image_b62cdcb0_0f31114a5f99a876.png
├── 1
│   ├── image_01e3b6b8_1a84fb440ea5b968.png
│   ├── image_2550784a_153ef007af111508.png
│   ├── image_5b44c158_12d7cf046f6fe8bd.png
│   ├── image_5b77c271_14638d8755dedaca.png
│   ├── image_80afe04b_1c9a44c90691726c.png
│   ├── image_98812780_1490599c23f9112c.png
│   ├── image_a7db514c_1aece22a74fc73d8.png
│   └── image_f0906e81_168ec49e960d4ed5.png
├── 2
│   ├── image_13706e6a_22bd87482567a99b.png
│   ├── image_2f255286_253b36a8a7bf806e.png
│   ├── image_75d51232_2e09a69c14bf1448.png
│   └── image_89e4ef41_25e4dca0acba2974.png
├── 3
│   ├── image_542f6c68_30ba1af451bd427f.png
│   ├── image_64558838_31044020f4b83ee9.png
│   ├── image_82e83904_3b598e7aa5b97124.png
│   ├── image_8944fca0_3d13d7d6e4a801a5.png
│   ├── image_944c2d9c_3f3eecd63b92e92f.png
│   ├── image_954a47fb_390e26535f8796f6.png
│   ├── image_acf5e52f_37d0d8794448aa41.png
│   ├── image_c063de78_3ecda443331c9f7f.png
│   └── image_f4ef0aba_35deaf9a4750bd55.png
├── 4
│   ├── image_4d6ebf24_4418cd3f1465386e.png
│   ├── image_8f8d46fc_467dc0dbdec75146.png
│   ├── image_a4812509_413082bc92dbdc66.png
│   └── image_f9c8dd8e_4be1a1fea8e141ba.png
├── 5
│   ├── image_1fc873a8_56b49472438f4bb7.png
│   ├── image_76aa4994_558621fd96b4a784.png
│   ├── image_9deda1be_5fc381b0b3408032.png
│   ├── image_a1f8476a_5ddbe8136b759cab.png
│   └── image_ba8b241e_5ad6d0bc2d846e1b.png
├── 6
│   ├── image_199010db_6b7ee709a09a5e77.png
│   ├── image_1a2946d0_69146c83a66be698.png
│   ├── image_89aa0d52_606a59bb3ade51e6.png
│   ├── image_e886233e_653a220871086c01.png
│   └── image_ff92c0ef_62466e130c819f4e.png
├── 7
│   ├── image_1e4cfeee_7e18cee9e2430925.png
│   ├── image_1f0d0faf_79cd90a19e4d9a71.png
│   ├── image_516726d1_7ad1cfe8c231c6ad.png
│   ├── image_52b9f1c7_758eb4dc795771d8.png
│   ├── image_5fe4be62_7cc5c68dc9f8025e.png
│   ├── image_9f6cbb21_76c7c43e77d2eba8.png
│   └── image_faf1b44b_7d404299bbcbf247.png
├── 8
│   ├── image_2e9dffec_85daef24107fc4bc.png
│   ├── image_4bd8fa8f_810856da124d1a10.png
│   ├── image_4e6c7258_86ee422829c6770c.png
│   ├── image_5d581740_8bc106bad5e44a46.png
│   └── image_eda3cfd4_87006ef3ec76124e.png
├── 9
│   ├── image_00693c9b_9ec3eba3de9dc24a.png
│   ├── image_10c7c008_9b554a079e05cf4d.png
│   ├── image_323de51d_9f37bcb3e0e9c6d0.png
│   ├── image_7f7732b2_9e295f648623874f.png
│   ├── image_bba8f742_9acea909640ec2a2.png
│   ├── image_e7a1fbd6_94a78e6f18126226.png
│   └── image_f97dfc4c_9b19d1e81d8fdb58.png
├── a
│   ├── image_6a3cc6c5_aebb285eca7ebc5f.png
│   ├── image_6f1334ad_a8a74febe2840f5b.png
│   ├── image_919ae9b9_a3ff880aaae6500b.png
│   ├── image_a1d71012_a2e08b0d3c5dd46a.png
│   ├── image_cc901c26_a5e1dcc6876f535a.png
│   └── image_f77d8b4d_ae6199ea2f66542c.png
├── b
│   ├── image_0708720a_b855ba31736e1ee7.png
│   ├── image_3aa4106b_b72fc8f1bcc31a21.png
│   ├── image_613b6f9c_becf5d08ebf4182f.png
│   ├── image_8f7b8bc7_b6f1fd9df80bf21b.png
│   ├── image_b6946213_b183cdcc84bfa2c1.png
│   └── image_ddb456fb_b2789ec5aa07de58.png
├── c
│   ├── image_22902267_c212cd18c920c77b.png
│   ├── image_40371f99_c39444669f32893f.png
│   ├── image_546c37c3_c4a3d2702e01012e.png
│   ├── image_59b04e82_cb5bcd450988c370.png
│   ├── image_71db8d7a_cffc69db7b33990a.png
│   ├── image_9c383f61_cfaa1cb64b3d0471.png
│   ├── image_b29aadd0_c17b3ff32d497b31.png
│   ├── image_e0233c99_c548c5cb54922111.png
│   └── image_fa2241f4_ccfd172a412782df.png
├── d
│   ├── image_04c7ccb1_de6158317f8ea250.png
│   ├── image_2486aba1_d9e38191aa90e7c8.png
│   ├── image_4d9a23f2_d9804038a5ce8eb9.png
│   ├── image_8be015fb_ddbf2b949a28e33b.png
│   ├── image_91764cf9_dc6db8bff4479ff5.png
│   ├── image_a2667440_d64aa2bfd843afd7.png
│   ├── image_dfaeea6f_d62af66b0fa43c84.png
│   └── image_fe9451ad_d8630271ff771c8f.png
├── e
│   ├── image_09fc3c76_ef7c0155dac41415.png
│   ├── image_49e1fa14_e0221310d8e22f38.png
│   ├── image_4dc6ee6f_e8ad002a0c10d615.png
│   ├── image_58032730_ecbabdedc61f90b5.png
│   ├── image_6edce5fb_e5a66b92fe528dce.png
│   ├── image_792822b4_ecffd097a111c603.png
│   ├── image_d1f5886a_ef24cb07e083f2ec.png
│   └── image_fe469931_e30c79ff4de3eb93.png
└── f
    ├── image_3d6679a0_f7c2796c3dff77c8.png
    ├── image_4a06f81b_f209ef349ad8eb16.png
    ├── image_7057fbc1_f054a75c7b1cde7f.png
    ├── image_70dcf698_f964bf5a38d4ee85.png
    ├── image_b3212710_ff0b4cc625bf818c.png
    ├── image_cfada8da_f711895ee35c3f77.png
    ├── image_db1ddf6f_f97654ee0099a136.png
    └── image_f93f5b92_fc8056a02298081d.png

http://devwiki/w/index.php?title=Special:Captcha/image&wpCaptchaId=1309964367 gives a 200 for me... But FF won't display it

Neither would http://devwiki/w/images/captcha/0/image_b62cdcb0_0f31114a5f99a876.png it gave me a forbidden error...

Looking on disk...

reedy@ubuntu64-web-esxi:/var/www/wiki/mediawiki/core$ ls -al images/captcha/0/
total 28
drwxrwxr-x  2 reedy reedy  4096 Sep 18 21:29 .
drwxrwxrwx 18 reedy reedy  4096 Sep 18 21:29 ..
-r----x--t  1 reedy reedy 18015 Sep 18 21:29 image_b62cdcb0_0f31114a5f99a876.png

That's definitely not right. The webserver is not run as reedy

A quick chmod a+r images/captcha/*/*.png fixed that... (note you can change ownership, change group etc)

reedy@ubuntu64-web-esxi:/var/www/wiki/mediawiki/core$ ls -al  ls -al images/captcha/0/
total 28
drwxrwxr-x  2 reedy reedy  4096 Sep 18 21:29 .
drwxrwxrwx 18 reedy reedy  4096 Sep 18 21:29 ..
-r--r-xr-t  1 reedy reedy 18015 Sep 18 21:29 image_b62cdcb0_0f31114a5f99a876.png`

How do your file permissions look?

Running GenerateFancyCaptchas.php as sudo -u www-data or similar might be better

TheDJ subscribed.

I'm provisionally closing this as a support request that was solved, but if a more fundamental issue still exists, feel free to open a new ticket with a full description of the problem.