Skip to content

Commit

Permalink
Added null check post status obj in sal site class (#39727)
Browse files Browse the repository at this point in the history
* Add null check for post_status_obj to avoid PHP Warnings

* changelog

* Ensure we only assign get_post_status_object to the parent status in case the parent exists
  • Loading branch information
darssen authored Oct 10, 2024
1 parent 875d6d7 commit 41f0994
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

SAL_Site class: Added null check to posts_status_obj to avoid Warnings
4 changes: 2 additions & 2 deletions projects/plugins/jetpack/sal/class.json-api-site-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,8 @@ private function user_can_view_post( $post ) {
if ( ! $post || is_wp_error( $post ) ) {
return false;
}

if ( 'inherit' === $post->post_status ) {
// If the post is of status inherit, check if the parent exists ( different to 0 ) to check for the parent status object.
if ( 'inherit' === $post->post_status && 0 !== (int) $post->post_parent ) {
$parent_post = get_post( $post->post_parent );
$post_status_obj = get_post_status_object( $parent_post->post_status );
} else {
Expand Down

0 comments on commit 41f0994

Please sign in to comment.