- Issue created by @roger.bertran
- last update
over 1 year ago 44 pass - 🇪🇸Spain roger.bertran Barcelona
I've created this patch to fix it, works for me.
- 🇩🇪Germany Anybody Porta Westfalica
Thanks for the report. Sorry, but the reason isn't really clear to me at the moment, and nobody reported this before. So we should find out, if this might be a project-specific configuration error or a general issue.
Your fix looks like a workaround, as
$font = $fonts[array_rand($fonts)];
should always return only one item. Why does it return more than one for you? Any ideas?
- 🇳🇱Netherlands corneboele
I'm encountering the same issue.
Yes,
$font = $fonts[array_rand($fonts)];
returns only one.But
$font = _image_captcha_get_font_uri($font);
doesn't.It returns an array of all fonts available, because in _image_captcha_get_font_uri it expects a token, but a font path is provided.
The fix works, even on 1.x, but is probably not the correct solution.
- Issue was unassigned.
- last update
over 1 year ago 44 pass - 🇳🇱Netherlands corneboele
Attached a new temporary patch for latest version.
- 🇳🇱Netherlands corneboele
@Anybody just that it applies to 1.12/2.x latest. But the patch is imo not the right solution, see #4. I think we need to fix that not a font path is given to `_image_captcha_get_font_uri`, but a token.
- Status changed to Needs work
over 1 year ago 3:03pm 27 July 2023 - 🇲🇦Morocco redamakhchan
I'm facing the same issue after I did a composer update today, for #04 🐛 Error 500 in image_captcha image Closed: cannot reproduce , the param is already a token I confirm (key value of the $fonts).
Just the
$fonts
recieved on param atcaptcha/modules/image_captcha/src/Service/ImageCaptchaRenderService.php:293
, are not the same$available_fonts
returned by_image_captcha_get_available_fonts_from_directories()
onweb/modules/contrib/captcha/modules/image_captcha/image_captcha.module:54
. the list is different, which cause the token to not be found. - 🇲🇦Morocco redamakhchan
ok found it I think
$fonts
returned on web/modules/contrib/captcha/modules/image_captcha/src/Service/ImageCaptchaRenderService.php:97:public function generateImage($code) { $fonts = _image_captcha_get_enabled_fonts();
Are not the same as $fonts returned on web/modules/contrib/captcha/modules/image_captcha/image_captcha.module:52 :
function _image_captcha_get_font_uri($token = NULL) { $fonts = [ 'BUILTIN' => 'BUILTIN', ]; $available_fonts = _image_captcha_get_available_fonts_from_directories(); foreach ($available_fonts as $file_token => $font_info) { $fonts[$file_token] = $font_info['uri']; } return ((!empty($token) && !empty($fonts[$token])) ? $fonts[$token] : $fonts); }
What fixed the issue for me is to do
drush updb
, after doing it I started to see common fonts. - 🇩🇪Germany Anybody Porta Westfalica
Did everyone here run update.php or
drush updb
after the update?
Any please also rundrush cr
afterwards. Who still has the issue then? - 🇩🇪Germany daveiano
Confirming that
drush updb
resolves the issue. I forgot to run it locally on my dev machine. - Status changed to Closed: cannot reproduce
over 1 year ago 1:17pm 31 July 2023 Our deployment process runs drush deploy, which I understand runs database updates and cache rebuild. However for the sake of completeness I ran
drush updb
anddrush cr
, and we are still seeing this issue.The suggestion from #5 of setting a font did resolve the error.
I've revisited this.
Now using drupal 10.0.11, captcha 2.0.5 and image_captcha 2.0.5 on a staging site and the error shows.
Using `drush updb` and `drush cr` does not resolve the issue.However, now after setting a font I'm no longer seeing the error.