[wp-trac] [WordPress Trac] #14787: Introduce get_edit_user_link()

WordPress Trac wp-trac at lists.automattic.com
Sun Aug 5 16:43:43 UTC 2012


#14787: Introduce get_edit_user_link()
-------------------------+-----------------------
 Reporter:  scribu       |       Owner:  ryan
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:  3.5
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+-----------------------
Changes (by SergeyBiryukov):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 Since [21364], if you try to log in as a subscriber, you'll get a blank
 screen.

 Here's a rundown of what happens:
 1. In `wp-login.php`, `get_edit_user_link()` is called: [[BR]]
  http://core.trac.wordpress.org/browser/trunk/wp-login.php?rev=21421#L628
 2. In `get_edit_user_link()`, `get_current_user_id()` and
 `current_user_can()` are called:
  http://core.trac.wordpress.org/browser/trunk/wp-includes/link-
 template.php?rev=21421#L1059
 3. Since cookies are not set yet, both functions fail and an empty string
 is returned.
 4. There's nowhere to redirect, so `exit()` in line 632 leaves you with a
 blank screen.
 5. If you refresh the page, the user's profile appears as expected, since
 cookies are already set and `wp_get_current_user()` returns the actual
 user.

 [attachment:14787.2.diff] fixes the issue by calling
 `wp_set_current_user()` before trying to get the profile link in `wp-
 login.php`. We could instead pass `$user->ID` to `get_edit_user_link()` to
 avoid `get_current_user_id()`, but `current_user_can()` would fail anyway.

 An alternative would be to revert to `admin_url( 'profile.php' )`.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14787#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list