Warning Array to String conversion coming from BP Better Messages
-
I noticed recent;y that PHP warnings are appearing in the site error log along these lines:
[09-Jun-2026 10:41:41 UTC] PHP Warning: Array to string conversion in ***/public_html/wp-includes/formatting.php on line 1128
At first I just ignored them, but with further digging I found out the cause: it is because during execution of BP Better Message code at some point a call is made to a BP core function ‘bp_cpre_fetch_avatar’, and this function eventually checks to see if get_wp_user_avatar_src is installed, and if so calls it. Now I have installed One User Avatar plugin and this provides an implementatiom of this method, but the signature of the provided method differs from that assumed by BP Better Messages. BP Better Messages does this:
if( function_exists('get_wp_user_avatar_src') ){ $return = get_wp_user_avatar_src( $params['item_id'], ['size' => $size] ); } else { $return = get_avatar_url($params['item_id'], ['size' => $size]); }So it passes the size option inside an array. However, One User Avatar defined the function as:
/**
* Return just the image src
* @since 1.1
* @param int|string $id_or_email
* @param int|string $size
* @param string $align
* @uses get_wp_user_avatar()
* @return string
*/
public function get_wp_user_avatar_src( $id_or_email = '', $size = '', $align = '' ) {So this expects a string/int, not an array. And so we now get an error / warning displayed.
So we have an inconsistency. My guess is that BP Better Messages has this wrong … but maybe someone could comment on this misalignment?
You must be logged in to reply to this topic.