Array to String Conversion Notice
-
There’s something up with one of your shortcodes that’s causing this PHP notice to be littered all throughout my debug.log file.
The notice I’m seeing in my log is:
[24-Jan-2020 17:14:35 UTC] PHP Notice: Array to string conversion in D:\home\site\wwwroot\wp-includes\shortcodes.php on line 325
As you can see, that is a WP core file. I’ve modified it so I could identify which shortcode was triggering it.
I modified this line in shortcodes.php (because this is the one that was having the error):
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];
To this:
$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; set_error_handler( function( $errno, $errstr, $errfile, $errline, $errcontext ) { // error was suppressed with the @-operator if ( 0 === error_reporting() ) { return false; } throw new ErrorException( $errstr, 0, $errno, $errfile, $errline ); }); try { $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; } catch( ErrorException $e ) { fc_debug_log( array( //'error' => $e, 'message' => $e->getMessage(), 'function_name' => $shortcode_tags[ $tag ], 'attributes' => $attr, //'content' => $content, 'tag' => $tag, 'm1' => $m[1], 'm6' => $m[6] ) ); } restore_error_handler();
Elsewhere in the file, I have this function for logging to my debug.log file:
function fc_debug_log($obj) { if (is_array($obj) || is_object($obj)) { error_log(print_r($obj, true)); } else { error_log($obj); } }
Anyway, I was able to identify that it’s coming from your plugin because this is what it outputted whenever I got the array to string conversion error:
[24-Jan-2020 17:14:35 UTC] PHP Notice: Array to string conversion in D:\home\site\wwwroot\wp-includes\shortcodes.php on line 325 [24-Jan-2020 17:14:35 UTC] Array ( [message] => Array to string conversion [function_name] => Array ( [0] => Skyword_Shortcode Object ( ) [1] => customfields_shortcode ) [attributes] => [tag] => cf [m1] => [m6] => )
Is there a reason why your function name is an array and not a string? Can you please update your plugin so it does not cause this notice in WP core? Thank you.
- The topic ‘Array to String Conversion Notice’ is closed to new replies.