Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#9899 closed enhancement (fixed)

edit_post_link() performs redundant permissions checking

Reported by: coffee2code Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.8
Component: General Keywords: has-patch tested
Focuses: Cc:


edit_post_link() duplicates permission checks that are already (and always) performed in get_edit_post_link().

edit_post_link() has checks to ensure current_user_can('edit_post', $post->ID) (and similar if it's a page). If the user can, then get_edit_post_link() is called, which repeats those checks.

The attached patch has edit_post_link() defer to get_edit_post_link() for the check. This eliminates code duplication and redundant processing, centralizes this permission checking, and removes lines of code; wins all around.

Patch is also compatible with changes I suggested in #9898.

Attachments (1)

9899.diff (879 bytes) - added by coffee2code 7 years ago.
Patch as mentioned in original submission.

Download all attachments as: .zip

Change History (3)

7 years ago

Patch as mentioned in original submission.

#1 @ryan
7 years ago

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

(In [11426]) eliminate duplicate cap checks. Props coffee2code. fixes #9899

#2 @ryan
7 years ago

  • Milestone changed from Unassigned to 2.8
Note: See TracTickets for help on using tickets.