sybrew / the-seo-framework

The SEO Framework WordPress plugin.
https://theseoframework.com/
GNU General Public License v3.0
417 stars 46 forks source link

Warnings on PHP 8.x #680

Closed ajitbohra closed 2 months ago

ajitbohra commented 3 months ago

We have plans to upgrade to 8.2 here https://github.com/sybrew/the-seo-framework/issues/644

In the meantime would it be good to fix some warnings on php8.x?

[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_canonical_uri" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 691
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noindex" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 706
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_nofollow" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 830
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noarchive" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 961
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_canonical_uri" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 691
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noindex" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 706
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_nofollow" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 830
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noarchive" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 961
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_canonical_uri" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 691
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noindex" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 706
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_nofollow" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 830
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noarchive" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 961
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_canonical_uri" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 691
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noindex" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 706
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_nofollow" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 830
[11-Jun-2024 23:13:48 UTC] PHP Warning:  Undefined array key "_genesis_noarchive" in /opt/wordpress/web/app/plugins/autodescription/inc/classes/admin/seobar/builder/page.class.php on line 961
sybrew commented 3 months ago

Hello!

TSF is compatible with PHP 7.4 ~ 8.3. The other ticket is about increasing the minimum requirements. Our websites currently work with PHP 8.1.

The plugin shouldn't emit warnings on any of the supported versions. But when it does, it's highly likely something on the site isn't working according to the standard APIs.

Here are some scenarios I figured from a dry run (ranked from difficulty to verify). With these scenarios, I expect you can see the warnings on your screen and not only via logs:

  1. I believe the SEO Bar outputting these warnings assesses a post with corrupted metadata. You should resave the post to fix the corrupted metadata; you may need to rewrite the custom SEO metadata if necessary. However, if the metadata is corrupted, you should've gotten more PHP warnings than just those.
  2. Alternatively, your site uses the SEO Bar for a post that isn't registered with WordPress (at the time the SEO Bar is rendered). This may be a conflict from a caching plugin. See if disabling the caching plugin resolves the issue, and review its settings when it does. If it does, it is likely to do with object caching, which can cause many more elusive issues.
  3. Or, the SEO Bar could've been assessing a post type that doesn't have SEO support. Please let me know if you created this post type or another plugin. If so, how or which?
  4. Or, either filter the_seo_framework_post_meta_defaults or the_seo_framework_post_meta are active and removing required keys. We found that no other public plugins filter these, so the site owner must have done this if this is an issue. I'd be happy to improve the filter.

Did any of this help find the cause?

sybrew commented 2 months ago

From other reports I've assimilated that there is a plugin active that calls the meta box before WordPress establishes what a post or page is. This meta box, with the SEO Bar embedded, tries to call a non-existing post object's metadata.

This shouldn't be a cause for concern, but it is a bug in another plugin, and it does indeed spawn unwanted errors.

These errors will no longer spawn from TSF v5.0.7 because we'll then always return the defaults: https://github.com/sybrew/the-seo-framework/commit/5bf612fa73298574924390f4a5dd238c7ab884f4. It doesn't resolve the issue where the meta box is called for no good reason, however.