Make WordPress Core

Changeset 58653

Timestamp:
07/03/2024 04:08:55 PM (5 weeks ago)
Author:
SergeyBiryukov
Message:

Users: Pass the previous state of the user as context to the wp_set_password hook.

Follow-up to [55056], [55250].

Props dd32.
Fixes #61541.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r57990 r58653  
    27692769        global $wpdb;
    27702770
     2771
     2772
    27712773        $hash = wp_hash_password( $password );
    27722774        $wpdb->update(
     
    27852787         *
    27862788         * @since 6.2.0
    2787          *
    2788          * @param string $password The plaintext password just set.
    2789          * @param int    $user_id  The ID of the user whose password was just set.
    2790          */
    2791         do_action( 'wp_set_password', $password, $user_id );
     2789         * @since 6.7.0 The `$old_user_data` parameter was added.
     2790         *
     2791         * @param string  $password      The plaintext password just set.
     2792         * @param int     $user_id       The ID of the user whose password was just set.
     2793         * @param WP_User $old_user_data Object containing user's data prior to update.
     2794         */
     2795        do_action( 'wp_set_password', $password, $user_id, $old_user_data );
    27922796    }
    27932797endif;
  • trunk/tests/phpunit/tests/auth.php

    r58341 r58653  
    116116     *
    117117     * @ticket 57436
     118
    118119     *
    119120     * @covers ::wp_set_password
     
    122123        $action = new MockAction();
    123124
    124         add_action( 'wp_set_password', array( $action, 'action' ) );
    125         wp_set_password( 'A simple password', self::$user_id );
     125        $previous_user_pass = get_user_by( 'id', $this->user->ID )->user_pass;
     126
     127        add_action( 'wp_set_password', array( $action, 'action' ), 10, 3 );
     128        wp_set_password( 'A simple password', $this->user->ID );
    126129
    127130        $this->assertSame( 1, $action->get_call_count() );
     131
     132
     133
    128134    }
    129135
Note: See TracChangeset for help on using the changeset viewer.