• Resolved rajandangi649

    (@rajandangi649)


    We’re getting this warning message on my site:
    Warning: Undefined array key "@id" in /../plugins/seo-by-rank-math/includes/modules/schema/class-frontend.php on line 243

    For your information, we are using PHP8 and Mariadb 10.4.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @rajandangi649,

    Thank you for contacting the support and sorry for the inconvenience caused.

    It seems like there is a corrupted Schema entry on the page where you are getting this error. Please remove the Schema you have applied from the page and the issue should be resolved after that.

    If you are not able to access the Schema tab of the meta box, please open your database find the wp_postmeta table and look for entries for the ID of the affected page with a meta key of rank_math_schema_[schema_name]. If you find entries like that with empty values for the meta_value column you can delete those as they might be causing the issue.

    Let us know how that goes. Looking forward to helping you.

    I am having the same issue with the same error message, not just for individual pages, but for whole categories of pages (Woocommerce orders, BuddyBoss members, BuddyBoss groups). I tried editing everything on the SEO Settings page, but was not able to resolve it.

    All my plugins are fully up-to-date, and I have the bbPress module turned on.

    I also tried looking for wp_postmeta entries, but turned up no rows with this query:

    select * from wp_postmeta
    WHERE meta_key LIKE 'rank_math_schema%'
    LIMIT 100

    Thanks for your help.

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @pmcelwee,

    As you’re getting the errors on archive pages as well, as per Google’s guidelines, the Product Schema should be used only on single product pages.

    Please head over to your WordPress admin area > Rank Math > Titles & Meta > [name of the archives types with the error or using the Product Schema], and enable the Remove Snippet Data option. This should remove the Schema data from these pages.

    As for the single product pages, please delete the Schema on a few pages and update them. Then, add the Schema again and after clearing your website’s cache, test those pages with Google’s Rich Results Testing Tool and see if that helps: https://search.google.com/test/rich-results

    Let us know how that goes.

    Thanks, but after poking around, I don’t think this has to do with the product schema or archives pages. (I see the error on pages and BuddyBoss pages. The former have the Article schema and the second shouldn’t have schema as far as I know. And in any case, it doesn’t seem to be modifiable by me.

    Instead, I think this is probably a bug introduced by upgrading to PHP8.0. (The OP was also using PHP8.) Here is the relevant code from the Frontend class, with a couple comments from me:

    /**
       * Remove Person entity if it is not referenced in any other entities.
       *
       * @param array $data Array of json-ld data.
       *
       * @return array
       */
      public function remove_person_entity( $data ) {
        if ( empty( $data['ProfilePage'] ) || ! is_singular() ) { /* SEEMS THAT THIS IF CLAUSE IS not working as intended */
          return $data;
        }
    
        $temp_data = $data;
        $id        = $temp_data['ProfilePage']['@id']; /* THIS IS THE LINE THAT ERRORS */
        $ids       = [];
    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @pmcelwee,

    Please check the source code of the pages that are triggering this warning and look for the Person Schema that is getting added to the page.

    What are the values and the properties you see there?

    Looking forward to hearing back from you.

    OK, after quite a bit of digging, I found a cause and a workaround: disabling the “BuddyPress” module in Rank Math makes the errors go away. … So perhaps there has been an update to BuddyBoss Platform or Theme that caused this to stop working correctly? I recently upgraded to BuddyBoss’s most recent Platform and Theme version, 2.0.7.

    I discovered that the error is generated when opening BuddyBoss member pages, or list pages that are nested under a member page, ie that start with “/members/{some-member}”

    For example, it occurs on https://sewliberated.com/members/patrick/ (which you have to be logged in to see. I’d be happy to set you up with an account for testing, perhaps on my staging server.)

    In the Apache log, it appeared to come from random pages (listed as a “referrer”) because certain logged-in user actions cause such messages to be pre-fetched.

    When I visit a member page directly, I still get an error message, but without the “referrer” information:

    [Tue Aug 09 15:42:25.043764 2022] [proxy_fcgi:error] [pid 29805:tid 140022929725184] [client 99.46.154.61:52912] AH01071: Got error ‘PHP message: PHP Warning: Undefined array key “@id” in /home/673753.cloudwaysapps.com/yvrqnvayfz/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/schema/class-frontend.php on line 243’

    Looking through the source code of a member page for schema, I only find an Organization schema (no Person):

    <script type="application/ld+json" class="rank-math-schema">{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://sewliberated.com/#organization","name":"Sew Liberated","logo":{"@type":"ImageObject","@id":"https://sewliberated.com/#logo","url":"https://sewliberated-1b3ad.kxcdn.com/wp-content/uploads/2021/12/sewliberated-logo-one-color-rgb-160x109-1.png","caption":"Sew Liberated","inLanguage":"en-US","width":"160","height":"109"}},{"@type":"WebSite","@id":"https://sewliberated.com/#website","url":"https://sewliberated.com","name":"Sew Liberated","publisher":{"@id":"https://sewliberated.com/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"#webpage","url":"","datePublished":"","dateModified":"","isPartOf":{"@id":"https://sewliberated.com/#website"},"inLanguage":"en-US"}]}</script>

    When the BuddyPress module is enabled, the error also occurs on all the nested pages I have tested. For example, on specific message pages ( https://sewliberated.com/members/patrick/messages/view/3/ ) and on BuddyBoss group listing pages (https://sewliberated.com/members/patrick/groups/) . In these cases, the schema on the page is the same, just Organization.

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello,

    Thank you for your patience.

    Please update Rank Math & all other plugins, themes and WordPress to the latest version.

    The issue should be fixed.

    If not, please feel free to open a support topic or reply to this message, and we will be more than happy to assist.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Warning: Undefined array key “@id”’ is closed to new replies.