Skip to content

fix displaying privacy policy on event on PHP8

rajeshs requested to merge github/fork/MegaphoneJon/privacy-policy-fix into master

Created by: MegaphoneJon

When Enable terms and Conditions Acceptance is set to Yes on an event when running PHP8, the event registration form crashes. PHP shows the following error:

TypeError: strlen(): Argument #1 ($string) must be of type string, array given in HTML_QuickForm_checkbox->toHtml() (line 138 of /home/jon/local/mysite/web/sites/all/modules/civicrm/packages/HTML/QuickForm/checkbox.php)

when using $form->add() with checkbox as the first argument, the fourth argument becomes the _text property - which must be a string, not an array. Empty arrays and NULL are treated the same in PHP7 but in PHP8 we must specify NULL or an empty string.

Merge request reports