Skip to content

Commit

Permalink
Comments: Use post_password_required() for comment capability checks.
Browse files Browse the repository at this point in the history
Follow-up to [56836], [57123].

Fixes #59929.

git-svn-id: https://develop.svn.wordpress.org/trunk@57285 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Jan 15, 2024
1 parent ba40e28 commit 56e16bd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ public function single_row( $item ) {
$edit_post_cap = $post ? 'edit_post' : 'edit_posts';

if ( ! current_user_can( $edit_post_cap, $comment->comment_post_ID )
&& ( ! empty( $post->post_password )
&& ( post_password_required( $comment->comment_post_ID )
|| ! current_user_can( 'read_post', $comment->comment_post_ID ) )
) {
// The user has no access to the post and thus cannot see the comments.
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ protected function comments_bubble( $post_id, $pending_comments ) {
$edit_post_cap = $post_object ? 'edit_post' : 'edit_posts';

if ( ! current_user_can( $edit_post_cap, $post_id )
&& ( ! empty( $post_object->post_password )
&& ( post_password_required( $post_id )
|| ! current_user_can( 'read_post', $post_id ) )
) {
// The user has no access to the post and thus cannot see the comments.
Expand Down
4 changes: 1 addition & 3 deletions src/wp-admin/includes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,8 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
}

foreach ( $possible as $comment ) {
$comment_post = get_post( $comment->comment_post_ID );

if ( ! current_user_can( 'edit_post', $comment->comment_post_ID )
&& ( ! empty( $comment_post->post_password )
&& ( post_password_required( $comment->comment_post_ID )
|| ! current_user_can( 'read_post', $comment->comment_post_ID ) )
) {
// The user has no access to the post and thus cannot see the comments.
Expand Down

0 comments on commit 56e16bd

Please sign in to comment.