Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP8.0 Fix type error passing in NULL when it expects an array #19

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

seamuslee001
Copy link
Contributor

This fixes a type error on a clients site running PHP8.0 the issue is that if you leave the say honeypot_form_ids settings black Civi::settings() will supply the default which is null and there for an array_key_exists and CRM_Utils_Array::value will supply the setting default value of NULL instead of []

This uses the ?? operator to ensure an array is passed through

Example settings array that was causing the issue var_dumped out

array(7) { ["honeypot_form_ids"]=> NULL ["honeypot_protect_all"]=> NULL ["honeypot_field_names"]=> array(1) { [0]=> string(3) "url" } ["honeypot_limit"]=> NULL ["honeypot_ipban"]=> NULL ["honeypot_event_ids"]=> NULL ["honeypot_protect_all_events"]=> string(1) "1" }

@monishdeb
Copy link
Contributor

I have tested on my local setup and agree with the fixes made. @elisseck can you please take look at this patch?

@elisseck elisseck merged commit 5ff4b0a into elisseck:master Oct 13, 2023
@elisseck
Copy link
Owner

Thanks! Sorry I haven't seen these. My assumption was that everyone has moved to using https://lab.civicrm.org/extensions/formprotection where matt included most of the relevant code from this extension plus new features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants