-
Notifications
You must be signed in to change notification settings - Fork 828
Prevent PHP fatals with robots_txt
filter
#44529
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
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
|
projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php
Outdated
Show resolved
Hide resolved
if ( ! is_string( $output ) ) { | ||
$output = ''; | ||
} | ||
|
||
$public = (int) $public; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, we may have to do like
$public = (int) get_option( 'blog_public' );
WordPress 6.8 started casting the value to bool before calling the hook (see WordPress/wordpress-develop@f01e8109), and wpcom picked that up too (see Automattic/wpcom@d84b7196). If we still want to handle the non-Core "-1" case (treating it as "extra-false" rather than true
as will be passed) in this hook, we'll need to refetch it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Addressed in 49cf5f4.
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable, haven't tested though.
One suggestion for a comment inline
projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php
Show resolved
Hide resolved
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
Looks like there's tests for this code that will need updating now that we re-fetch the option. |
Closes MONOREP-47
If bad data was passed to the
robots_txt
filter (e.g.null
) we'd get a fatal, since the data should be a string. This resets the param to an empty string if it isn't already a string.I recently became aware of another set of logs to monitor, and this popped up as an easy but important one to fix.
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
You can probably reproduce with by adding filter, but the code should be pretty straightforward.