diff --git a/projects/plugins/jetpack/changelog/update-added-null-check-post-status-obj-in-sal-site-class b/projects/plugins/jetpack/changelog/update-added-null-check-post-status-obj-in-sal-site-class new file mode 100644 index 0000000000000..84cfd9c0cd835 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-added-null-check-post-status-obj-in-sal-site-class @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +SAL_Site class: Added null check to posts_status_obj to avoid Warnings diff --git a/projects/plugins/jetpack/sal/class.json-api-site-base.php b/projects/plugins/jetpack/sal/class.json-api-site-base.php index 8109037452d83..ea2342955e33f 100644 --- a/projects/plugins/jetpack/sal/class.json-api-site-base.php +++ b/projects/plugins/jetpack/sal/class.json-api-site-base.php @@ -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 {