[wp-trac] [WordPress Trac] #47005: check if SERVER_PROTOCOL is empty in load.php

WordPress Trac noreply at wordpress.org
Sun Apr 21 07:12:59 UTC 2019


#47005: check if SERVER_PROTOCOL is empty in load.php
--------------------------+-----------------------------
 Reporter:  malthert      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-----------------------------
 In php cli requests, the server_protocol may not be set, throwing a notice
 This should be changed in /wp-includes/wp-load.php

 {{{
 function wp_get_server_protocol() {
         $protocol = $_SERVER['SERVER_PROTOCOL'];
         if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2',
 'HTTP/2.0' ) ) ) {
                 $protocol = 'HTTP/1.0';
         }
         return $protocol;
 }
 }}}

 to this:

 {{{
 function wp_get_server_protocol() {
         $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ?
 $_SERVER['SERVER_PROTOCOL'] : '';
         if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2',
 'HTTP/2.0' ), true ) ) {
                 $protocol = 'HTTP/1.0';
         }
         return $protocol;
 }
 }}}

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


More information about the wp-trac mailing list