-
Notifications
You must be signed in to change notification settings - Fork 823
SAL_Site: Prevent warnings due to reading properties on null #44195
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
SAL_Site: Prevent warnings due to reading properties on null #44195
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! Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryThis PR did not change code coverage! That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷 |
if ( | ||
( 'trash' === $post->post_status && current_user_can( 'edit_post', $post->ID ) ) | ||
|| 'auto-draft' === $post->post_status | ||
) { | ||
$authorized = true; | ||
} |
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.
Not a blocker, but we could check here if $authorized was already set to true, and not evaluate. Similar how it was before with the short-circuit logic.
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 idea - added in 4adf206
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.
Thanks for working on this one @coder-karen
Changes look good from a code review perspective. Left a minor comment.
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.
LGTM 👍
Co-authored-by: Juanma Rodriguez Escriche <juanma.rodriguez.escriche@automattic.com>
Fixes VULCAN-228
Proposed changes:
user_can_view_post
function, specifically with regard to checking the$parent_post
, and therefore the$post_status_obj
value. Bothget_post
andget_post_status_object
can return null so we should allow for that, and ensure the rest of the code continues processing as before if these values are null.Logs: e1891edb5a21bf2c639db4455ebc23cc-logstash
Other information:
Jetpack product discussion
pdWQjU-1g0-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Code-review
You can also test this by visiting the URL mentioned in the Linear issue, and then on trunk observing a new entry in the above linked Logstash logs.
If you are have sandboxed
https://public-api. wordpress.com/
, you should also see an error while tailing for errors:tail -f /tmp/php-errors
You can confirm the change prevents the warning and doesn't impact the output by using the commands in the generated comment below and sandboxing
https://public-api. wordpress.com/
, while tailing for errors. No errors should be generated.