Problem/Motivation
TypeError: Argument 1 passed to _image_captcha_check_fonts() must be of the type array, null given, called in /var/www/html/drupal8/modules/captcha/image_captcha/image_captcha.module on line 213 in /var/www/html/drupal8/modules/captcha/image_captcha/image_captcha.module on line 115 #0 /var/www/html/drupal8/modules/captcha/image_captcha/image_captcha.module(213): _image_captcha_check_fonts(NULL)\n#1 /var/www/html/drupal8/modules/captcha/image_captcha/image_captcha.module(257): _image_captcha_check_setup()\n#2 [internal function]: image_captcha_captcha('list')\n#3 /var/www/html/drupal8/modules/captcha/src/Service/CaptchaService.php(37): call_user_func_array('image_captcha_c...', Array)\n#4 /var/www/html/drupal8/modules/captcha/src/Form/CaptchaSettingsForm.php(105): Drupal\\captcha\\Service\\CaptchaService->getAvailableChallengeTypes(false)\n#5 [internal function]: Drupal\\captcha\\Form\\CaptchaSettingsForm->buildForm(Array, Object(Drupal\\Core\\Form\\FormState))\n#6 /var/www/html/drupal8/core/lib/Drupal/Core/Form/FormBuilder.php(532): call_user_func_array(Array, Array)\n#7 /var/www/html/drupal8/core/lib/Drupal/Core/Form/FormBuilder.php(278): Drupal\\Core\\Form\\FormBuilder->retrieveForm('captcha_setting...', Object(Drupal\\Core\\Form\\FormState))\n#8 /var/www/html/drupal8/core/lib/Drupal/Core/Controller/FormController.php(91): Drupal\\Core\\Form\\FormBuilder->buildForm(Object(Drupal\\captcha\\Form\\CaptchaSettingsForm), Object(Drupal\\Core\\Form\\FormState))\n#9 [internal function]: Drupal\\Core\\Controller\\FormController->getContentResult(Object(Symfony\\Component\\HttpFoundation\\Request), Object(Drupal\\Core\\Routing\\RouteMatch))\n#10 /var/www/html/drupal8/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)\n#11 /var/www/html/drupal8/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#12 /var/www/html/drupal8/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\\Core\\Render\\Renderer->executeInRenderContext(Object(Drupal\\Core\\Render\\RenderContext), Object(Closure))\n#13 /var/www/html/drupal8/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)\n#14 /var/www/html/drupal8/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber->Drupal\\Core\\EventSubscriber\\{closure}()\n#15 /var/www/html/drupal8/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#16 /var/www/html/drupal8/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#17 /var/www/html/drupal8/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#18 /var/www/html/drupal8/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#19 /var/www/html/drupal8/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache->pass(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#20 /var/www/html/drupal8/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\page_cache\\StackMiddleware\\PageCache->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#21 /var/www/html/drupal8/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#22 /var/www/html/drupal8/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#23 /var/www/html/drupal8/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#24 /var/www/html/drupal8/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#25 {main},
Drupal 8.9.14, captcha 8.x-1.2, php 7.3
I'm not sure since when this started to happening.
Steps to reproduce
Browse to /admin/config/people/captcha
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3215760-6-argument_must_be_type_array.patch | 1.23 KB | fjgarlin |
Comments
Comment #2
lordzik commentedComment #3
larisse commentedHi! I can't reproduce this error. For me, works ok.
Comment #4
BartNijs commentedI have the same issue. PHP 7.3.
Comment #5
BartNijs commentedUninstalling and reinstalling solved the issue for me.
Comment #6
fjgarlin commentedDid this happen after a big update on this module? If that's the case it might be that the "image_captcha_fonts" setting was not properly set.
Uninstalling and installing makes sure that the field gets installed, but if you don't want to lose configuration it might be a good idea to try to fix the field on-the-fly.
The attached patch does that. It checks that there are fonts, and if nothing is returned (which will provoke the above issue), then it tries to reinstall the fonts needed for the module to work. If that also fails, then it just returns one of the invalid status values.
Comment #8
japerryLooks reasonable. Fixed!