Skip to content

Commit ee5c6b5

Browse files
Only apply post based permissions to ‘comment’ type
1 parent 25a4050 commit ee5c6b5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,11 +1890,7 @@ protected function check_read_post_permission( $post, $request ) {
18901890
* @return bool Whether the comment can be read.
18911891
*/
18921892
protected function check_read_permission( $comment, $request ) {
1893-
if ( 0 === get_current_user_id() ) {
1894-
return false;
1895-
}
1896-
1897-
if ( ! empty( $comment->comment_post_ID ) ) {
1893+
if ( 'comment' === $comment->comment_type && ! empty( $comment->comment_post_ID ) ) {
18981894
$post = get_post( $comment->comment_post_ID );
18991895
if ( $post ) {
19001896
if ( $this->check_read_post_permission( $post, $request ) && 1 === (int) $comment->comment_approved ) {
@@ -1903,6 +1899,10 @@ protected function check_read_permission( $comment, $request ) {
19031899
}
19041900
}
19051901

1902+
if ( 0 === get_current_user_id() ) {
1903+
return false;
1904+
}
1905+
19061906
if ( empty( $comment->comment_post_ID ) && ! current_user_can( 'moderate_comments' ) ) {
19071907
return false;
19081908
}

0 commit comments

Comments
 (0)