wordpress-seo
wordpress-seo copied to clipboard
Undefined property: WP_Error::$taxonomy
- [x] I've read and understood the contribution guidelines.
- [x] I've searched for any related issues and avoided creating a duplicate issue.
Please give us a description of what happened.
Since a couple of days, Yoast now generates these warnings on repeat:
PHP Warning: Undefined property: WP_Error::$taxonomy in /srv/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 151
PHP Warning: Undefined property: WP_Error::$taxonomy in /srv/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 210
PHP Warning: Undefined property: WP_Error::$taxonomy in /srv/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 176
PHP Warning: Undefined property: WP_Error::$taxonomy in /srv/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 182
Each of these try to access $this->source->taxonomy.
Please describe what you expected to happen and why.
No warnings.
How can we reproduce this behavior?
- I don't know…
- … but given this forum entry, it might be related to some name collision: That is, my WP might use some taxonomy name that conflicts with another.
- So it would be good to add an isset check to the first warning occurrence and print more details in case of that error, rather than leave the user guessing. (Unfortunately I don't know enough about your code to know what relevant fields
$thisandsourceprovide to that effect.)
Used versions
- WordPress version: 6.0.1
- Yoast SEO version: 19.4
- WooCommerce: 6.7.0
- PHP 8.0.21
- Tested with theme: Divi
We are facing the same error but in another file
/wp-content/plugins/wordpress-seo/src/builders/indexable-hierarchy-builder.php
Notice: Undefined property: WP_Error::$taxonomy
on line 326.
Full error log:
ErrorException: Notice: Undefined property: WP_Error::$taxonomy
#31 /wp-content/plugins/wordpress-seo/src/builders/indexable-hierarchy-builder.php(326): Yoast\WP\SEO\Builders\Indexable_Hierarchy_Builder::get_term_parents
#30 /wp-content/plugins/wordpress-seo/src/builders/indexable-hierarchy-builder.php(219): Yoast\WP\SEO\Builders\Indexable_Hierarchy_Builder::add_ancestors_for_term
#29 /wp-content/plugins/wordpress-seo/src/builders/indexable-hierarchy-builder.php(116): Yoast\WP\SEO\Builders\Indexable_Hierarchy_Builder::build
#28 /wp-content/plugins/wordpress-seo/src/repositories/indexable-hierarchy-repository.php(87): Yoast\WP\SEO\Repositories\Indexable_Hierarchy_Repository::find_ancestors
#27 /wp-content/plugins/wordpress-seo/src/repositories/indexable-repository.php(420): Yoast\WP\SEO\Repositories\Indexable_Repository::get_ancestors
#26 /wp-content/plugins/wordpress-seo/src/generators/breadcrumbs-generator.php(132): Yoast\WP\SEO\Generators\Breadcrumbs_Generator::generate
#25 /wp-content/plugins/wordpress-seo/src/presentations/indexable-presentation.php(749): Yoast\WP\SEO\Presentations\Indexable_Presentation::generate_breadcrumbs
#24 /wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php(64): Yoast\WP\SEO\Presentations\Abstract_Presentation::__get
#23 /wp-content/plugins/wordpress-seo/src/generators/schema/breadcrumb.php(33): Yoast\WP\SEO\Generators\Schema\Breadcrumb::generate
#22 /wp-content/plugins/wordpress-seo/src/generators/schema-generator.php(128): Yoast\WP\SEO\Generators\Schema_Generator::generate_graph
#21 /wp-content/plugins/wordpress-seo/src/generators/schema-generator.php(76): Yoast\WP\SEO\Generators\Schema_Generator::generate
#20 /wp-content/plugins/wordpress-seo/src/presentations/indexable-presentation.php(738): Yoast\WP\SEO\Presentations\Indexable_Presentation::generate_schema
#19 /wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php(64): Yoast\WP\SEO\Presentations\Abstract_Presentation::__get
#18 /wp-content/plugins/wordpress-seo/src/presenters/schema-presenter.php(60): Yoast\WP\SEO\Presenters\Schema_Presenter::get
#17 /wp-content/plugins/wordpress-seo/src/presenters/schema-presenter.php(44): Yoast\WP\SEO\Presenters\Schema_Presenter::present
#16 /wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php(324): Yoast\WP\SEO\Integrations\Front_End_Integration::present_head
#15 /wp-includes/class-wp-hook.php(303): WP_Hook::apply_filters
#14 /wp-includes/class-wp-hook.php(327): WP_Hook::do_action
#13 /wp-includes/plugin.php(470): do_action
#12 /wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php(298): Yoast\WP\SEO\Integrations\Front_End_Integration::call_wpseo_head
#11 /wp-includes/class-wp-hook.php(303): WP_Hook::apply_filters
#10 /wp-includes/class-wp-hook.php(327): WP_Hook::do_action
#9 /wp-includes/plugin.php(470): do_action
#8 /wp-includes/general-template.php(3015): wp_head
#7 /wp-content/themes/cyan/header.php(18): require_once
#6 /wp-includes/template.php(770): load_template
#5 /wp-includes/template.php(716): locate_template
#4 /wp-includes/general-template.php(48): get_header
#3 /wp-content/themes/cyan/search.php(10): include
#2 /wp-includes/template-loader.php(106): require_once
#1 /wp-blog-header.php(19): require
#0 /index.php(17): null
Used versions
- php Version: 7.4.3
- WordPress Version: 5.8.2
- Yoast SEO Version: 18.9
+1 here:
Undefined property: WP_Error::$taxonomy
in Yoast\WP\SEO\Presentations\Indexable_Term_Archive_Presentation::is_multiple_terms_query called at /var/www/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php (64)
in Yoast\WP\SEO\Presentations\Indexable_Term_Archive_Presentation::generate_canonical called at /var/www/wp-content/plugins/wordpress-seo/src/presentations/abstract-presentation.php (64)
in Yoast\WP\SEO\Presentations\Abstract_Presentation::__get called at /var/www/wp-content/plugins/wordpress-seo/src/presenters/canonical-presenter.php (50)
in Yoast\WP\SEO\Presenters\Canonical_Presenter::get called at /var/www/wp-content/plugins/wordpress-seo/src/presenters/abstract-indexable-tag-presenter.php (37)
in Yoast\WP\SEO\Presenters\Abstract_Indexable_Tag_Presenter::present called at /var/www/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php (326)
in Yoast\WP\SEO\Integrations\Front_End_Integration::present_head called at /var/www/wp-includes/class-wp-hook.php (308)
in WP_Hook::apply_filters called at /var/www/wp-includes/class-wp-hook.php (332)
in WP_Hook::do_action called at /var/www/wp-includes/plugin.php (517)
in do_action called at /var/www/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php (300)
in Yoast\WP\SEO\Integrations\Front_End_Integration::call_wpseo_head called at /var/www/wp-includes/class-wp-hook.php (308)
in WP_Hook::apply_filters called at /var/www/wp-includes/class-wp-hook.php (332)
in WP_Hook::do_action called at /var/www/wp-includes/plugin.php (517)
in do_action called at /var/www/wp-includes/general-template.php (3043)
in wp_head called at /var/www/wp-content/themes/theme/header.php (15)
in require_once called at /var/www/wp-includes/template.php (783)
in load_template called at /var/www/wp-includes/template.php (718)
in locate_template called at /var/www/wp-includes/general-template.php (48)
in get_header called at /var/www/wp-content/themes/theme/category.php (5)
in include called at /var/www/wp-includes/template-loader.php (106)
in require_once called at /var/www/wp-blog-header.php (19)`
Used versions
PHP Version: 8.0
WordPress Version: 6.1.1
Yoast SEO Version: 19.9
Those warnings still seem relevant with the latest versions --
Yoast SEO version: 20.3 Elementor version: 3.11.5. TwentyTwenty: 2.1 WordPress: 6.1.1 PHP version: 7.4.1 / 8.0.0
To reproduce:
- Create any landing page in Elementor
- Activate Yoast SEO
- Open the landing page (logged in or public doesn’t matter)
- Taxonomy warnings/notices showing on top of the content
Warning: Attempt to read property "taxonomy" on null in /Volumes/Neil/flywheel/yoast-seo/app/public/wp-content/plugins/wordpress-seo/src/helpers/current-page-helper.php on line 488
Warning: Undefined property: WP_Error::$taxonomy in /Volumes/Neil/flywheel/yoast-seo/app/public/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 163
Warning: Undefined property: WP_Error::$taxonomy in /Volumes/Neil/flywheel/yoast-seo/app/public/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 188
Warning: Undefined property: WP_Error::$taxonomy in /Volumes/Neil/flywheel/yoast-seo/app/public/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 194
Warning: Undefined property: WP_Error::$taxonomy in /Volumes/Neil/flywheel/yoast-seo/app/public/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 222
+1 https://wordpress.org/support/topic/taxonomy-issues-on-elementor
Related (internal) issue: https://yoast.atlassian.net/browse/IM-1358
Any news here? We had to deactivate Yoast for this reason, but it's hurting our SEO now...
+1 https://wordpress.org/support/topic/yoast-seo-y-elementor-error-landing/
- add error management in e.g. this case where a
WP_Errorcan be returned - could be related to some cases where non-public taxonomies are processed by a flow which they are not supposed to follow
- it seems that it's trying to create an indexable for a non-existing taxonomy
@twwn @ArneGockeln @manuelRod @funnelmatix we are investigating and we may have found why it happens in certain conditions. Can you tell us which is the permalink structure in the sites you are experiencing the issue?
@enricobattocchi thank you for following up here. The permalink structure is set to /%category%/%postname%/. If I remember correctly, any custom permalink structure creates this issue.
Again, the issue only exists for pages built under landing pages, and only if an SEO plugin like Yoast or Rank Math are activated.
@twwn @ArneGockeln @manuelRod @funnelmatix these are the results of our investigation:
- We have been able to reproduce the issue only with the permalink structure set to
/%category%/%postname%/. - In this case, the Landing pages from Elementor are affected by a bug that makes them match the rewrite rules in a way that they could be recognized as category archives instead of as posts of a custom type. This is also confirmed by Query Monitor - see image:
- The Elementor team is already aware of that. It should be noted that the Landing pages are labeled as an Ongoing experiment currently in beta status, as you can see in the Elementor settings.
- Besides the warnings that you are experiencing, there are other less visible but more important problems triggered by this bug, such as an incomplete Schema output, missing canonical etc.
- Considering that the Landing pages feature is causing the problem, and taking into account its experimental/beta status, there is nothing we can do on our side to fix the issue.
- Our suggestion would be to use another permalink structure that doesn't trigger the problem with the Landing pages, though we know that it might be a problem and even discouraged switching to another URL structure if your site is already well-established and indexed.
- Our other suggestion, which doesn't apply just to this issue, is to make sure that warnings don't get put out in the body of the page on a production site. While setting
WP_DEBUGtotrueis fine while developing the site, once it's public it should be set tofalseand/or error reporting should be set in a way that only selected messages are logged in a file, but never thrown into the frontend of your website. Setting up the debug report in the right way will prevent such messages to be displayed on the page, though you should be aware that this doesn't solve the incomplete Schema, missing canonical, etc.
I can confirm this issue in another site with latest version:
[11-Sep-2023 15:51:55 UTC] PHP Warning: Undefined property: WP_Error::$taxonomy in /public_html/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 180
[11-Sep-2023 15:51:55 UTC] PHP Warning: Attempt to read property "term_id" on null in /public_html/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 99
[11-Sep-2023 15:51:55 UTC] PHP Warning: Undefined property: WP_Error::$taxonomy in /public_html/wp-content/plugins/wordpress-seo/src/presentations/indexable-term-archive-presentation.php on line 186
So the file on https://github.com/Yoast/wordpress-seo/blob/trunk/src/presentations/indexable-term-archive-presentation.php#L99 calls get_queried_object() without a is_wp_error() check that usually is suggested by various static analysis tools.
if ( ! empty( $this->model->object_id ) || is_null( \get_queried_object() ) ) {
return \get_term( $this->model->object_id, $this->model->object_sub_type );
}
https://github.com/Yoast/wordpress-seo/blob/trunk/src/presentations/indexable-term-archive-presentation.php#L175 also for another patch
if ( is_wp_error( $this->source ) || $this->model->title ) {
return $this->model->title;
}
Is a tiny patch...