TypeError: Return value of Civi\Formprotection\Recaptcha::shouldAddCaptchaToForm() must be of the type bool, null returned in Civi\Formprotection\Recaptcha->shouldAddCaptchaToForm() (line 360
If you visit a create link for a profile that does NOT have the add_captcha field checked, you get a crash. There's three things wrong I think with the loop:
- The ufGroupIDs array is not an array of ids, it's the profile data, e.g.
array ( 'id' => 2, 'is_active' => NULL, 'group_type' => NULL ...
, so the$addCaptcha
gets set to NULL, hence the error. - In the case where the add_captcha field is not checked, the value of the add_captcha field is NULL not FALSE, so it would have the same problem even if checking the right thing.
- Even if it were a group if IDs, the loop is saying if ANY of the profiles have it set to use captcha then use captcha. But this may be unimportant if the array is only ever expected to contain one id, i.e. the currently viewed thing. It's re-used for petition etc and I'm not sure yet what it looks like there.
The right fix depends on (3).