Opened 7 years ago
Closed 7 years ago
#47005 closed defect (bug) (fixed)
check if SERVER_PROTOCOL is empty in load.php
| Reported by: | malthert | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.3 |
| Component: | Bootstrap/Load | Version: | 5.2 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
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;
}
Attachments (1)
Change History (4)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Yes @malthert , it did throw a warning. I have added a patch as per your suggestion.