Skip to content

Commit 2f0af73

Browse files
check_read_permission - return false early if no user
1 parent 831fbaa commit 2f0af73

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,10 @@ 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+
18931897
if ( ! empty( $comment->comment_post_ID ) ) {
18941898
$post = get_post( $comment->comment_post_ID );
18951899
if ( $post ) {
@@ -1899,10 +1903,6 @@ protected function check_read_permission( $comment, $request ) {
18991903
}
19001904
}
19011905

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)