WordPress.org

Make WordPress Core

#45745 closed enhancement (fixed)

wp_new_user_notification should use get_password_reset_key

Reported by: spacedmonkey Owned by: 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 21 months 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 21 months ago.
Added error handling for WP_Error class

Download all attachments as: .zip

Change History (11)

#1 @spacedmonkey
21 months ago

  • Keywords good-first-bug added

#2 @spacedmonkey
21 months ago

CCing @mikeschroder for background on this one.

#3 @spacedmonkey
21 months ago

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

#4 @SergeyBiryukov
21 months ago

  • Description modified (diff)

@mrasharirfan
21 months 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
21 months 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
21 months 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
21 months ago

Added error handling for WP_Error class

#7 @desrosj
17 months 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
14 months ago

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

#9 @SergeyBiryukov
14 months 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.