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

Warning: Attempt to read property "ID" on int - RankMath\Frontend\Frontend::rss_replace_vars at line 279 #298

Open
apermo opened this issue Feb 13, 2025 · 0 comments

Comments

@apermo
Copy link

apermo commented Feb 13, 2025

Describe the bug
My sentry reported:

ErrorException
Warning: Attempt to read property "ID" on int

/seo-by-rank-math/includes/frontend/class-frontend.php in RankMath\Frontend\Frontend::rss_replace_vars at line 279

To Reproduce
The error was thrown in the rss search template.

The last part of the call stack where it leaves our code is: the_excerpt_rss();
After that it's WordPress core and rankmath.

Expected behavior
Fail gracefully.

In line 271 there is already a check for is_object() but in line 279 the $post is expected to be an instance of WP_Post

I suggest to wrap line 279 in a similar check, and on top, I suggest to replace the if ( is_object( $post ) ) with if ( $post instanceof \WP_Post ) in both cases.

Screenshots

Image

Desktop (please complete the following information):
irrelevant

Smartphone (please complete the following information):
irrelevant

Additional context
none

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

No branches or pull requests

1 participant