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 | Owned by: | 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&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)
Change History (5)
#1
@
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
@
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.
Note: See
TracTickets for help on using
tickets.
Removes second unnecessary check for sufficient user permissions in wp-admin/edit-comments.php