[wp-trac] [WordPress Trac] #51736: wp_remote_retrieve_header returns an Array for multiple headers

WordPress Trac noreply at wordpress.org
Fri Dec 10 19:19:56 UTC 2021

#51736: wp_remote_retrieve_header returns an Array for multiple headers
 Reporter:  robtarr         |       Owner:  johnjamesjacoby
     Type:  task (blessed)  |      Status:  assigned
 Priority:  normal          |   Milestone:  5.9
Component:  HTTP API        |     Version:  2.7
 Severity:  normal          |  Resolution:
 Keywords:  needs-patch     |     Focuses:  docs
Changes (by hellofromTonya):

 * keywords:  dev-feedback needs-patch => needs-patch


 >specifying a header that has multiple entries in the response this method
 returns an array

 Are you meaning that the `$response['headers'][ $header ]` could have an
 array of header entries for a single header name?

 If that's possible, then the question is: Should this function ''always''
 return only a string data type, i.e. a single header entry of string type?

 * If yes, then additional checks are needed and potentially an error would
 be thrown when it's not a string.

 * If no, then the code consuming `wp_remote_retrieve_header()` needs
 auditing to determine if additional checks are required to properly handle
 either a string or array. Looking at the code, there are instances where
 the returned value is passed to a native PHP function which will result in
 an error or deprecation on PHP 8+.

 @johnjamesjacoby is this something on your list before 5.9 Beta 3?

Ticket URL: <https://core.trac.wordpress.org/ticket/51736#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list