rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

PHP Warning with the Table of Content: Undefined array key "titleWrapper" #281

Open MathieuLamiot opened 4 months ago

MathieuLamiot commented 4 months ago

Describe the bug Rankmath Version 1.0.219 WordPress is reporting many PHP Warnings linked to SEO by Rank Math plugin. It seems to happen when loading a page using the table of content block from the RankMath plugin. Here are details about the warning report on my website on Sentry: https://mathieu-lamiot.sentry.io/share/issue/da8c94003d2642e9b56b8b572fc4a3dc/

The warning comes from: /wp-content/plugins/seo-by-rank-math/includes/modules/schema/blocks/toc/class-block-toc.php in RankMath\Schema\Block_TOC::render_toc_block_content at line 103 for Warning: Undefined array key "titleWrapper". In my case, from the Sentry report:

$parsed_block = {

   attrs: {

      headings: [
         13 items
      ],
      listStyle: ul
   },
   blockName: rank-math/toc-block,
   innerBlocks: [],

   innerContent: [
      1 item
   ]
}

To Reproduce Steps to reproduce the behavior:

  1. Create a WP post with the "Table of content" block from SEO By Rank Math.
  2. Visit the page
  3. Check PHP warnings.

Expected behavior If it is expected that titleWrapper can be undefined, the plugin should not create warnings ; with a check and bail-out for instance. If it is not expected for titleWrapper to be undefined, then this case should not occur.

Screenshots NA

Desktop (please complete the following information):