Post Druapl 10 Upgrade, Image Captcha not loading correctly on custom sites..

Issue fork captcha-3403329

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Tushar1 created an issue. See original summary.

kuldeep_mehra27’s picture

Assigned: tushar1 » kuldeep_mehra27
kuldeep_mehra27’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new24.57 KB

Tested on Drupal 10.1.6. Working as expected.

pbouchereau’s picture

Status: Reviewed & tested by the community » Active
pbouchereau’s picture

Ok. The title and description are broad.
The patch though is very specific and now that I've looked at it I understand why the issue was closed.
I still leave it open for visibility.

pbouchereau’s picture

Assigned: kuldeep_mehra27 » Unassigned
Status: Active » Reviewed & tested by the community

Wow... I really need some sleep.
I confused the "Working as expected" comment with the status.
Sorry for the noise on this issue.
I suppose it's ok to unassign @kuldeep_mehra27 ?

Status: Reviewed & tested by the community » Needs work

The last submitted patch, Error_500_image_captcha_image_issue.patch, failed testing. View results

japerry made their first commit to this issue’s fork.

japerry’s picture

Status: Needs work » Needs review

Dug into this a little, and the cause appears to be `image_captcha.settings:image_captcha_fonts` stores fonts as sha256 tokens of the font file path. If the path changes, the stored tokens no longer match.

The patch above gets around it with `reset()`, which only happens to return 'BUILTIN' because that is the first array entry. It also leaves the per-character directory rescan in place. I've taken a different approach in the new branch/MR:

  • printString() now resolves the configured font tokens once. It skips any token that no longer matches an installed font and falls back to the built-in font if none are left. A stale config now degrades gracefully instead of breaking the form.
  • A new kernel test covers stale tokens alone and next to a valid font. Without the fix it fails with the same TypeError.

Re-saving the fonts on the Image CAPTCHA settings page still restores your chosen fonts. #2985060: Moving the module in the file system breaks configured fonts deals with keeping the bundled font tokens stable when the module moves, so the config does not go stale in the first place.

  • japerry committed 0c55de4c on 2.x
    fix: #3403329 Skip unknown image CAPTCHA font tokens instead of crashing
    
japerry’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.