Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSS feeds cause fatal error with missing/invalid user #21381

Open
1 of 11 tasks
rmccue opened this issue May 14, 2024 · 1 comment
Open
1 of 11 tasks

RSS feeds cause fatal error with missing/invalid user #21381

rmccue opened this issue May 14, 2024 · 1 comment
Labels

Comments

@rmccue
Copy link

rmccue commented May 14, 2024

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

RSS (etc) feeds can cause a fatal error due to invalid typing from core.

To Reproduce

Step-by-step reproduction instructions

Expected results

Actual results

Screenshots, screen recording, code snippet

E_ERROR Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, bool given in /usr/src/app/content/plugins/wordpress-seo/src/integrations/front-end/feed-improvements.php:147
Stack trace:
#0 /usr/src/app/content/plugins/wordpress-seo/src/integrations/front-end/feed-improvements.php(107): Yoast\WP\SEO\Integrations\Front_End\Feed_Improvements->get_url_for_queried_object('https://www...')
#1 /usr/src/app/wordpress/wp-includes/class-wp-hook.php(312): Yoast\WP\SEO\Integrations\Front_End\Feed_Improvements->send_canonical_header(false)
#2 /usr/src/app/wordpress/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters('', Array)
#3 /usr/src/app/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#4 /usr/src/app/wordpress/wp-includes/functions.php(1631): do_action('do_feed_rss2', false, 'rss2')
#5 /usr/src/app/wordpress/wp-includes/template-loader.php(48): do_feed()
#6 /usr/src/app/wordpress/wp-blog-header.php(19): require_once('/usr/src/app/wo...')
#7 /usr/src/app/index.php(21): require('/usr/src/app/wo...')
#8 {main}
  thrown

On these lines:

protected function get_url_for_queried_object( $url = '' ) {
$queried_object = \get_queried_object();
// Don't call get_class with null. This gives a warning.
$class = ( $queried_object !== null ) ? \get_class( $queried_object ) : null;

This is caused by get_queried_object() returning false - this isn't a documented return type, but it can occur in a couple of ways. In this case, it's caused by WP_Query setting $query->queried_object to the result of get_userdata(), which can return false in various cases.

While it shouldn't return false for a valid author page, it is possible to do so based on other behaviour or plugins, which then becomes a fatal error rather than a 500 or 404. The code in Yoast handles null only, but should handle both null and false return values. (Additionally, core should really be coercing this from a false to a null so that it's typesafe, but it doesn't right now.)

Technical info

  • If relevant, which editor is affected (or editors):
  • Block Editor
  • Gutenberg Editor
  • Elementor Editor
  • Classic Editor
  • Other: n/a, core behaviour
  • Which browser is affected (or browsers):
  • Chrome
  • Firefox
  • Safari
  • Other:

Used versions

  • Device you are using:
  • Operating system:
  • PHP version:
  • WordPress version:
  • WordPress Theme:
  • Yoast SEO version:
  • Gutenberg plugin version:
  • Elementor plugin version:
  • Classic Editor plugin version:
  • Relevant plugins in case of a bug:

(Filing this on behalf of a customer; cc @zsheaib)

@josevarghese
Copy link
Contributor

Hi @rmccue

Thanks for using the Yoast SEO plugin and also for creating the issue. The issue you have noticed seems to be related to this one: #20436 or #20000.

If you are interested, you can also contribute to our plugin by submitting a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants