[wp-trac] [WordPress Trac] #44403: WP_Error object is not returned. Only assigned to a variable

WordPress Trac noreply at wordpress.org
Tue Jun 19 07:51:27 UTC 2018


#44403: WP_Error object is not returned. Only assigned to a variable
------------------------------+-----------------------------
 Reporter:  subrataemfluence  |      Owner:  (none)
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Users             |    Version:  trunk
 Severity:  normal            |   Keywords:  needs-patch
  Focuses:                    |
------------------------------+-----------------------------
 Function: wp_validate_user_request_key
 File: wp-includes/user.php
 Line no.: 3512

 According to the doc comment the above function should return wither a
 boolean value or a WP_Error object.


 {{{
 * @return bool|WP_Error WP_Error on failure, true on success.
 }}}


 At line number 3512 the WP_Error object is stored in a variable but never
 returned.

 {{{#!php
 <?php
 ...
 if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) {
    return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
 }

 if ( ! $expiration_time || time() > $expiration_time ) {
    $return = new WP_Error( 'expired_key', __( 'The confirmation email has
 expired.' ) ); // Line no. 3512. The new error object was never returned.
 }

 return true;

 }}}

 Shouldn't it be

 {{{#!php
 <?php
 if ( ! $expiration_time || time() > $expiration_time ) {
    return new WP_Error( 'expired_key', __( 'The confirmation email has
 expired.' ) );
 }
 }}}


 like the code block just above it?

 I am uploading a proposed patch for this. Please let me know if this
 works.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44403>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list