Make WordPress Core

Ticket #44500: 44500.diff

File 44500.diff, 2.0 KB (added by desrosj, 7 years ago)
  • src/wp-admin/includes/user.php

     
    771771        $request_ids = $requests_query->posts;
    772772
    773773        foreach ( $request_ids as $request_id ) {
    774                 wp_update_post( array(
    775                         'ID'            => $request_id,
    776                         'post_status'   => 'request-failed',
    777                         'post_password' => '',
    778                 ) );
     774                wp_mark_user_request_failed( $request_id );
    779775        }
    780776}
    781777
  • src/wp-includes/user.php

     
    34773477/**
    34783478 * Validate a user request by comparing the key with the request's key.
    34793479 *
     3480 * If determined that the request is expired, it will be transitioned to the `request-failed` status.
     3481 *
    34803482 * @since 4.9.6
    34813483 *
    34823484 * @param string $request_id ID of the request being confirmed.
     
    35323534        }
    35333535
    35343536        if ( ! $expiration_time || time() > $expiration_time ) {
     3537                wp_mark_user_request_failed( $request_id );
    35353538                return new WP_Error( 'expired_key', __( 'The confirmation email has expired.' ) );
    35363539        }
    35373540
     
    35583561}
    35593562
    35603563/**
     3564 * Marks a user_request post as failed.
     3565 *
     3566 * @param int $request_id User request ID.
     3567 * @return int|WP_Error Post ID when updated successfully, WP_Error on failure.
     3568 */
     3569function wp_mark_user_request_failed( $request_id ) {
     3570        $post = get_post( $request_id );
     3571
     3572        if ( ! $post ) {
     3573                return new WP_Error( 'invalid_request_id',  __( 'Invalid request ID.' ) );
     3574        } elseif ('user_request' !== $post->post_type ) {
     3575                return new WP_Error( 'invalid_post_type', __( 'The specified post is not a user_request post.' ) );
     3576        }
     3577
     3578        return wp_update_post(
     3579                array(
     3580                        'ID'            => $request_id,
     3581                        'post_status'   => 'request-failed',
     3582                        'post_password' => '',
     3583                ),
     3584                true
     3585        );
     3586}
     3587
     3588/**
    35613589 * WP_User_Request class.
    35623590 *
    35633591 * Represents user request data loaded from a WP_Post object.