{"id":12362393,"date":"2020-01-24T17:25:36","date_gmt":"2020-01-24T17:25:36","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/array-to-string-conversion-notice\/"},"modified":"2020-01-24T17:30:13","modified_gmt":"2020-01-24T17:30:13","slug":"array-to-string-conversion-notice","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/array-to-string-conversion-notice\/","title":{"rendered":"Array to String Conversion Notice"},"content":{"rendered":"<p>There&#8217;s something up with one of your shortcodes that&#8217;s causing this PHP notice to be littered all throughout my debug.log file.<\/p>\n<p>The notice I&#8217;m seeing in my log is:<br \/>\n<code>[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<\/code><\/p>\n<p>As you can see, that is a WP core file. I&#8217;ve modified it so I could identify which shortcode was triggering it.<\/p>\n<p>I modified this line in shortcodes.php (because this is the one that was having the error):<br \/>\n<code>$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];<\/code><\/p>\n<p>To this:<\/p>\n<pre><code>$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];\n\tset_error_handler( function( $errno, $errstr, $errfile, $errline, $errcontext ) {\n\t    \/\/ error was suppressed with the @-operator\n\t    if ( 0 === error_reporting() ) { return false; }\n\t    throw new ErrorException( $errstr, 0, $errno, $errfile, $errline );\n\t});\n\ttry {\n\t\t$output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];\n\t} catch( ErrorException $e ) {\n\t\tfc_debug_log( array(\n\t\t\t\/\/&#039;error&#039; =&gt; $e,\n\t\t\t&#039;message&#039; =&gt; $e-&gt;getMessage(),\n\t\t\t&#039;function_name&#039; =&gt; $shortcode_tags[ $tag ],\n\t\t\t&#039;attributes&#039; =&gt; $attr,\n\t\t\t\/\/&#039;content&#039; =&gt; $content,\n\t\t\t&#039;tag&#039; =&gt; $tag,\n\t\t\t&#039;m1&#039; =&gt; $m[1],\n\t\t\t&#039;m6&#039; =&gt; $m[6]\n\t\t) );\n\t}\n\trestore_error_handler();<\/code><\/pre>\n<p>Elsewhere in the file, I have this function for logging to my debug.log file:<\/p>\n<pre><code>function fc_debug_log($obj)\n{\n    if (is_array($obj) || is_object($obj)) {\n        error_log(print_r($obj, true));\n    } else {\n        error_log($obj);\n    }\n}<\/code><\/pre>\n<p>Anyway, I was able to identify that it&#8217;s coming from your plugin because this is what it outputted whenever I got the array to string conversion error:<\/p>\n<pre><code>[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\n[24-Jan-2020 17:14:35 UTC] Array\n(\n    [message] =&gt; Array to string conversion\n    [function_name] =&gt; Array\n        (\n            [0] =&gt; Skyword_Shortcode Object\n                (\n                )\n\n            [1] =&gt; customfields_shortcode\n        )\n\n    [attributes] =&gt; \n    [tag] =&gt; cf\n    [m1] =&gt; \n    [m6] =&gt; \n)<\/code><\/pre>\n<p>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.<\/p>\n","protected":false},"template":"","class_list":["post-12362393","topic","type-topic","status-publish","hentry","topic-tag-array-to-string-conversion"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12362393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12362393\/revisions"}],"predecessor-version":[{"id":12362409,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12362393\/revisions\/12362409"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12362393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}