[wp-trac] [WordPress Trac] #44686: Invalid return statement when request status is checked

WordPress Trac noreply at wordpress.org
Tue Jul 31 20:00:37 UTC 2018


#44686: Invalid return statement when request status is checked
--------------------------+-----------------------------
 Reporter:  moikano       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Users         |    Version:  4.9.7
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Currently in wp_validate_user_request_key(), when controls the status of
 request, it return a string instead a WP_Error object (
 [https://core.trac.wordpress.org/browser/tags/4.9.7/src/wp-
 includes/user.php#L3393] ).

 I don't know if the message is correct too.

 Now it is:
 {{{#!php
 if ( ! in_array( $request->status, array( 'request-pending', 'request-
 failed' ), true ) ) {
         return __( 'This link has expired.' );
 }
 }}}

 I think it would be something like:
 {{{#!php
 if ( ! in_array( $request->status, array( 'request-pending', 'request-
 failed' ), true ) ) {
         return new WP_Error( 'user_request_error', __( 'Invalid request.'
 ) );
 }
 }}}

 I think It is important because this function return bool **true** when
 all is correct and a string it is also **true** (if not strict checked).

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


More information about the wp-trac mailing list