[wp-trac] [WordPress Trac] #57512: Warning as a part of API response

WordPress Trac noreply at wordpress.org
Sat Feb 4 05:15:05 UTC 2023


#57512: Warning as a part of API response
-------------------------------------------------+-------------------------
 Reporter:  kalpeshh                             |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  REST API                             |     Version:  6.1.1
 Severity:  normal                               |  Resolution:
 Keywords:  2nd-opinion php8 has-unit-tests      |     Focuses:  rest-api
  has-patch                                      |
-------------------------------------------------+-------------------------

Comment (by kalpeshh):

 Count should be exactly 2, instead of limit for BasicAuth.

 @shooper what are your thoughts on below change to make code more
 readable?

 Instead of,

 {{{
 $exploded_basic_auth = explode( ':', $userpass );
 if ( 2 !== count($exploded_basic_auth) ) {
     return;
 }

 $_SERVER['PHP_AUTH_USER'] = $exploded_basic_auth[0];
 $_SERVER['PHP_AUTH_PW']   = $exploded_basic_auth[1];
 }}}

 can we use,

 {{{
 $exploded_basic_auth = explode( ':', $userpass );
 if ( 2 !== count($exploded_basic_auth) ) {
     return;
 }

 list( $user, $pass ) = $exploded_basic_auth;
 $_SERVER['PHP_AUTH_USER'] = $user;
 $_SERVER['PHP_AUTH_PW']   = $pass;
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57512#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list