fix: #3324321 Check for GD directly in the image CAPTCHA install requirements

Closes #3324321

The install-time requirements check (_image_captcha_install_requirements(), called from image_captcha_requirements() and, on Drupal 11.2+, from ImageCaptchaRequirements) included image_captcha.module and tested a hard-coded copy of IMAGE_CAPTCHA_ERROR_NO_GDLIB against the bitmask from _image_captcha_check_setup(). That helper references ImageCaptchaConstants, which cannot be autoloaded before the module is installed, so on a host without GD the check fatals instead of reporting the requirement error.

This checks function_exists('imagepng') directly (the same test the helper makes) and drops the include, the magic number and the @todo. The other & uses of _image_captcha_check_setup() are correct bitmask tests and are unchanged.

ImageCaptchaRequirementsTest (kernel) runs the install requirements check with image_captcha uninstalled and asserts that it does not load image_captcha.module. It fails without the fix. Full suite green on Drupal 10.6.6 and 11.

Merge request reports

Loading
Loading