Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
support59

Unsupported ACF column creates notice

Dear AdminColumns employee,

When we are creating a column for an unsupported ACF field, for example a Google Map field, the following PHP notice occurs:
Notice: Array to string conversion in /path/to/wordpress/wp-content/plugins/admin-columns-pro/addons/acf/classes/Column/Unsupported.php on line 12.
This happens because in /path/to/wordpress/wp-content/plugins/admin-columns-pro/addons/acf/classes/Column/Unsupported.php, line 12, the result of the get_field() function is casted to a string. However, in this case,get_field() returns an array. And this is a problem, because that cannot be casted to a string.
The best would to use something like this for returning the value as a string:


	public function get_value( $id ) {
		$value = get_field( $this->get_meta_key(), $id );
		$value = is_scalar( $value ) ? (string) $value : wp_json_encode( $value );
	}

This would then convert the value to json.
There are also other options for removing the notice, by falling back to an empty string '', serialize() the array, or using var_export().

We see this warning continuously, as we are attempting to add support for the ACF Google Maps field in our theme using the ac/column/value filter, but that does not bypass getting the field value, and thus creating this notice.

I hope I’ve been able to help to resolve this bug in a future version. If there are questions, please feel free to send a reply.
Thank you in advance and kind regards,

Menno van den Ende
Level Level

1 year, 11 months ago
Stefan van den Dungen Gronovius
Developer

Hi Menno,

Thank you very much for your input.
Consider this patched in the next version of Admin Columns Pro.
I do feel more for a notice that a value format (array/object) is not supported instead of just showing the JSON-encoded string, but I’ll have another thought about that.

1 year, 11 months ago
support59

Hi Stefan,

Thank you for your fast reply.
I can imagine now that you point this out, that you don’t want to show the data of the array as there might be irrelevant information in there, and sometimes even just a lot of information.
In that case it might indeed be better to indeed show a notice, or just an empty string.
Which one is better I will leave up to you .

Thanks for taking a look so fast, I will wait for the next version :).

Kind regards,

Menno van den Ende
Level Level

1 year, 11 months ago

You must be logged in to reply to this topic.