Make WordPress Core

Ticket #44940: 44940-breaking.diff

File 44940-breaking.diff, 2.2 KB (added by johnjamesjacoby, 12 months ago)
  • src/wp-includes/class-wp-user-request.php

     
    116116                $this->confirmed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_confirmed_timestamp', true );
    117117                $this->completed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_completed_timestamp', true );
    118118                $this->request_data        = json_decode( $post->post_content, true );
    119                 $this->confirm_key         = $post->post_password;
     119
     120                // See: https://core.trac.wordpress.org/ticket/44940
     121                if ( ! empty( $post->post_password ) ) {
     122                        $this->confirm_key = $post->post_password;
     123                } else {
     124                        // Backwards compatibility for requests lacking a confirm key.
     125                        $this->confirm_key = wp_generate_user_request_key( $post->ID );
     126                }
    120127        }
    121128}
  • src/wp-includes/user.php

     
    48454845                        array(
    48464846                                'action'      => 'confirmaction',
    48474847                                'request_id'  => $request_id,
    4848                                 'confirm_key' => wp_generate_user_request_key( $request_id ),
     4848                                'confirm_key' => $request->confirm_key,
    48494849                        ),
    48504850                        wp_login_url()
    48514851                ),
     
    49684968 * Returns a confirmation key for a user action and stores the hashed version for future comparison.
    49694969 *
    49704970 * @since 4.9.6
     4971 * @since 6.9.0 Request ID optional. See: https://core.trac.wordpress.org/ticket/44940
    49714972 *
    4972  * @param int $request_id Request ID.
     4973 * @param int $request_id Optional. Request ID. Default 0.
    49734974 * @return string Confirmation key.
    49744975 */
    4975 function wp_generate_user_request_key( $request_id ) {
     4976function wp_generate_user_request_key( $request_id = 0 ) {
    49764977        // Generate something random for a confirmation key.
    49774978        $key = wp_generate_password( 20, false );
    49784979
    4979         // Save the key, hashed.
    4980         wp_update_post(
    4981                 array(
    4982                         'ID'            => $request_id,
    4983                         'post_status'   => 'request-pending',
    4984                         'post_password' => wp_fast_hash( $key ),
    4985                 )
    4986         );
     4980        // Maybe save the hashed key to the request, if ID passed.
     4981        if ( $request_id ) {
     4982                wp_update_post(
     4983                        array(
     4984                                'ID'            => $request_id,
     4985                                'post_status'   => 'request-pending',
     4986                                'post_password' => wp_fast_hash( $key ),
     4987                        )
     4988                );
     4989        }
    49874990
    49884991        return $key;
    49894992}