{"id":19038249,"date":"2026-10-06T21:55:58","date_gmt":"2026-10-06T21:55:58","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/array-to-string-conversion-in-execute-cache-php1039-breeze_commented_posts\/"},"modified":"2026-10-06T21:55:58","modified_gmt":"2026-10-06T21:55:58","slug":"array-to-string-conversion-in-execute-cache-php1039-breeze_commented_posts","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/array-to-string-conversion-in-execute-cache-php1039-breeze_commented_posts\/","title":{"rendered":"Array to string conversion in execute-cache.php:1039 (breeze_commented_posts)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We see this warning in the PHP error log of a site running Breeze 2.6.1 (it was the same on 2.6.0):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PHP Warning:  Array to string conversion in ...\/wp-content\/plugins\/breeze\/inc\/cache\/execute-cache.php on line 1039<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Cause: <code>Breeze_Execute_Cache::get_wp_logged_in_cookie_value()<\/code> loops over every cookie and casts the value to a string before checking the cookie name:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>foreach ( $_COOKIE as $cookie_name =&gt; $cookie_value ) {\n    $cookie_name  = (string) $cookie_name;\n    $cookie_value = (string) $cookie_value;   \/\/ line 1039\n    \/\/ the wordpress_logged_in_ name check comes only after this<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Breeze itself sets the cookie <code>breeze_commented_posts[&lt;post_id&gt;]<\/code> for visitors who left a comment (<code>inc\/cache\/purge-cache.php<\/code>, line 174), and reads it back as an array in <code>execute-cache.php<\/code> (line 977). PHP parses a cookie name with square brackets into an array, so <code>$_COOKIE['breeze_commented_posts']<\/code> is an array, and the cast on line 1039 raises the warning when such a visitor opens a page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps to reproduce:<\/p>\n\n\n\n<ol>\n<li>Enable page cache in Breeze.<\/li>\n\n\n\n<li>Leave a comment as a guest on any post, so the browser gets <code>breeze_commented_posts[123]<\/code>.<\/li>\n\n\n\n<li>Open any page: the warning appears in the PHP error log.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Suggested fix: skip non-string values before the cast, or check the name first, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>foreach ( $_COOKIE as $cookie_name =&gt; $cookie_value ) {\n    if ( ! is_string( $cookie_value ) ) {\n        continue;\n    }\n    $cookie_name = (string) $cookie_name;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The value of such a cookie can never be a <code>wordpress_logged_in_<\/code> cookie anyway, so skipping it does not change the behaviour of the check.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"template":"","class_list":["post-19038249","topic","type-topic","status-publish","hentry","topic-tag-cookie","topic-tag-php-warning"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19038249","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":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19038249\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19038249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}