{"id":19023560,"date":"2026-09-18T14:42:01","date_gmt":"2026-09-18T14:42:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/php-warning-undefined-array-key-html-in-embedpressblockrenderer-php-1672\/"},"modified":"2026-09-18T14:42:01","modified_gmt":"2026-09-18T14:42:01","slug":"php-warning-undefined-array-key-html-in-embedpressblockrenderer-php-1672","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/php-warning-undefined-array-key-html-in-embedpressblockrenderer-php-1672\/","title":{"rendered":"PHP Warning: Undefined array key &#8220;html&#8221; in EmbedPressBlockRenderer.php 1672"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;m getting a recurring PHP warning from EmbedPress on a production site.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Environment<\/p>\n\n\n\n<ul>\n<li>EmbedPress 4.6.6 (free version, no Pro)<\/li>\n\n\n\n<li>WordPress 7.1.1<\/li>\n\n\n\n<li>PHP 8.3.31<\/li>\n\n\n\n<li>Rank Math SEO (generates the XML sitemaps)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The warning<br \/>PHP Warning: Undefined array key &#8220;html&#8221; in<br \/>\/wp-content\/plugins\/embedpress\/EmbedPress\/Gutenberg\/EmbedPressBlockRenderer.php on line 1672<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It fires about 90 times a day (373 times over the last four days). Around 97% of the<br \/>occurrences happen while Rank Math renders the XML sitemaps (\/post-sitemap5.xml and<br \/>similar, requested by search engine crawlers), the rest on single blog posts that<br \/>contain Facebook and Instagram embeds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The cause<br \/>In render_displayable_content() (line 1656), $embed can be either a string or an array,<br \/>and the array is not guaranteed to contain an &#8216;html&#8217; key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (is_array($embed)) {\n    echo $embed&#091;'html'];   \/\/ line 1672\n} else {\n    echo $embed;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Two more spots in the same function make the same assumption:<\/p>\n\n\n\n<ul>\n<li>Line 1661: $embed[&#8216;html&#8217;] .= $styling[&#8216;custom_branding&#8217;][&#8216;html&#8217;];<br \/>Same undefined key warning when custom branding is enabled.<\/li>\n\n\n\n<li>Line 1668: $embed .= Helper::embed_content_share($content_id, $attributes);<br \/>This concatenates a string onto $embed without checking whether it is an array. On<br \/>PHP 8 that is a fatal TypeError (&#8220;Unsupported operand types: array . string&#8221;), not a<br \/>warning. I have not hit it, presumably because content share is disabled here, but it<br \/>looks like a crash waiting to happen for anyone who enables that option on a provider<br \/>that returns an array.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Suggested fix<br \/>Normalising $embed to a string once, at the top of the function, would fix all three:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private static function render_displayable_content($embed, $content_share, $content_id, $attributes, $styling = &#091;])\n{\n    $html = is_array($embed) ? ($embed&#091;'html'] ?? '') : (string) $embed;\n\n    if (!empty($styling&#091;'custom_branding']&#091;'html'])) {\n        $html .= $styling&#091;'custom_branding']&#091;'html'];\n    }\n\n    if (!empty($content_share)) {\n        $html .= Helper::embed_content_share($content_id, $attributes);\n    }\n\n    echo $html;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">One question: is it expected for a provider to return an array without an &#8216;html&#8217; key, or<br \/>does that point to an upstream problem in how the embed is fetched? If the array is<br \/>malformed, silencing the warning would only hide the real issue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;m happy to test a patch on this site if that helps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks!<\/p>\n","protected":false},"template":"","class_list":["post-19023560","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19023560","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\/19023560\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19023560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}