PHP 8 Fatal Error in Spam Check – preg_split(): Argument #2 ($subject) must be of type string, array given

Hi everyone,

I’m hoping someone can point me in the right direction.

We’re seeing the following fatal error when a Gravity Form is submitted:

Fatal error: Uncaught TypeError: preg_split(): Argument #2 ($subject) must be of type string, array given

The stack trace shows:

Gravity_Remote_Blacklist->check_if_entery_is_spam()
GFCommon::is_spam_entry()
GFFormDisplay::handle_submission()

The fatal error occurs on this line in a plugin called gravity-remote-blacklist-api:

preg_split(...)

where the second argument is an array instead of a string.

My questions are:

  • Has Gravity Forms changed the values passed to spam filter hooks in recent versions?
  • Are add-ons expected to handle array values for field types such as Name, Address, Checkboxes, Multi Select, List fields, etc.?
  • Is this simply a PHP 8 compatibility issue where the plugin should be checking is_array() before calling preg_split()?
  • Has anyone else encountered this with custom spam-check plugins?

From the stack trace, it appears the error originates in the third-party plugin rather than Gravity Forms itself, but I’m trying to determine whether a change in Gravity Forms exposed a compatibility issue that older plugins weren’t expecting.

Any advice or pointers to the relevant documentation would be greatly appreciated.

Thanks!

Has Gravity Forms changed the values passed to spam filter hooks in recent versions?

There have been no changes to what is passed to the gform_is_entry_spam filter.

Are add-ons expected to handle array values for field types such as Name, Address, Checkboxes, Multi Select, List fields, etc.?

Yes, they either need to manually get and evaluate each input value, or they can use the following field method, which for built-in fields returns a string containing the entire field value.

$value = $field->get_value_export( $entry );

Is this simply a PHP 8 compatibility issue where the plugin should be checking is_array() before calling preg_split()?

Probably. You’ll need to contact the add-on developer to confirm.