Make WordPress Core

Opened 17 years ago

Closed 15 years ago

#5811 closed defect (bug) (fixed)

wp-admin/edit-comments.php unnecessarily checks twice for user permissions

Reported by: hansengel's profile hansengel Owned by: hansengel's profile hansengel
Milestone: 2.9 Priority: normal
Severity: minor Version: 2.5
Component: Administration Keywords: needs-patch
Focuses: Cc:

Description

It's easier to just show you the current code (as of [6772]):

    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
	echo "<a href='comment.php?action=editcomment&amp;c=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
		$url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
		echo "<a href='$url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . "</a> ";
		} ?></td>

I don't see any point in repeatedly checking if the user has sufficient permissions on the same page. Let's simplify it a bit and check for user permissions once.

Attachments (1)

5811.r6772.diff (1.2 KB) - added by hansengel 17 years ago.
Removes second unnecessary check for sufficient user permissions in wp-admin/edit-comments.php

Download all attachments as: .zip

Change History (5)

@hansengel
17 years ago

Removes second unnecessary check for sufficient user permissions in wp-admin/edit-comments.php

#1 @ryan
17 years ago

That puts the td tags inside the conditional. I think they need to always be there even when the user doesn't have the proper caps. In that case they would be empty.

#2 @hansengel
17 years ago

  • Status changed from new to assigned

Just checked it out—without my patch when the user doesn't have enough permissions, there are two empty columns at the end of each row. With the patch, they're not shown and the View link extends over where the other two columns would be. So it's actually better to use it this way, IMHO.

#3 @Denis-de-Bernardy
15 years ago

  • Keywords needs-patch added; has-patch tested removed

#4 @westi
15 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

Closing as FIXED as this code no longer exits in wp-admin/edit-comments.php and _wp_comment_row only checks the cap once.

Note: See TracTickets for help on using tickets.