Hi, after upgrading to PHP 8.1 my the ACF relationship field started failing. The problem seems to be inside the library itself, any advice how to fix? Thanks.
FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-relationship.php:261
I attempted a hotfix myself to make my site work as per advice here:
https://stackoverflow.com/questions/66671269/fatal-error-uncaught-typeerror-count-argument-1-var-must-be-of-type-cou
// add as optgroup or results
if ( is_countable($args['post_type']) && count( $args['post_type'] ) == 1 ) {
$results = $results[0]['children'];
}
$args[‘post_type’] should never not be an array at this point in the code. The only reason that it could be is that there is an acf/fields/relationship/query filter setting the query arg value to a string rather than an array.