Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#45745 closed enhancement (fixed)

wp_new_user_notification should use get_password_reset_key

Reported by: spacedmonkey's profile spacedmonkey Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 4.4
Component: Users Keywords: good-first-bug has-patch needs-refresh
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Since the function get_password_reset_key was introducted in [34923] it means, there is now repeated logic in the function wp_new_user_notification has repeated logic. This should be replaced.

Attachments (2)

45745.diff (1.9 KB) - added by mrasharirfan 6 years ago.
I have replaced the repeated logic in wp_new_user_notification for password reset key with get_password_reset_key function.
45745.1.diff (1.9 KB) - added by mrasharirfan 6 years ago.
Added error handling for WP_Error class

Download all attachments as: .zip

Change History (11)

#1 @spacedmonkey
6 years ago

  • Keywords good-first-bug added

#2 @spacedmonkey
6 years ago

CCing @mikeschroder for background on this one.

#3 @spacedmonkey
6 years ago

  • Description modified (diff)
  • Keywords needs-patch added

#4 @SergeyBiryukov
6 years ago

  • Description modified (diff)

@mrasharirfan
6 years ago

I have replaced the repeated logic in wp_new_user_notification for password reset key with get_password_reset_key function.

#5 follow-up: @spacedmonkey
6 years ago

  • Keywords has-patch added; needs-patch removed

Thanks for @mrasharirfan the first patch.

The only thing I would change, is add a little error handling. get_password_reset_key can return a WP_Error. So there should be the following check added.

if ( is_wp_error( $key ) ) {
    return;
}

#6 in reply to: ↑ 5 @mrasharirfan
6 years ago

@spacedmonkey you're right. Thanks for the tip 💯

The only thing I would change, is add a little error handling. get_password_reset_key can return a WP_Error. So there should be the following check added.

if ( is_wp_error( $key ) ) {
    return;
}

@mrasharirfan
6 years ago

Added error handling for WP_Error class

#7 @desrosj
5 years ago

  • Keywords needs-refresh added
  • Owner set to mrasharirfan
  • Status changed from new to assigned

45745.1.diff needs to be refreshed against trunk.

Assigning to mark good first bug claimed.

#8 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner changed from mrasharirfan to SergeyBiryukov
  • Status changed from assigned to reviewing

#9 @SergeyBiryukov
5 years ago

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

In 45712:

Users: Use get_password_reset_key() in wp_new_user_notification().

Props mrasharirfan, spacedmonkey.
Fixes #45745.

Note: See TracTickets for help on using tickets.