[wp-trac] [WordPress Trac] #47733: Undefined index HTTP_HOST in wp-includes/ms-settings.php on line 57

WordPress Trac noreply at wordpress.org
Thu Jul 18 17:10:16 UTC 2019


#47733: Undefined index HTTP_HOST in wp-includes/ms-settings.php on line 57
----------------------------+-----------------------------
 Reporter:  JochenT         |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Bootstrap/Load  |    Version:  5.2.2
 Severity:  minor           |   Keywords:  needs-patch
  Focuses:  multisite       |
----------------------------+-----------------------------
 We get requests on our server of the form

 {{{
 175.143.12.??? - - [30/Jun/2019:10:22:45 +0200] "GET / HTTP/1.0" 500 73873
 "-" "-" (dinse.eu)
 }}}
 This request uses HTTP/1.0 and results in a status code 500. The related
 entry in the PHP error log is

 {{{
         [30-Jun-2019 08:22:45 UTC] PHP Notice:  Undefined index: HTTP_HOST
 in /usr/www/xxxx/wp-includes/ms-settings.php on line 57
 }}}
 1. In ms-settings.php on line 57 it is not checked if
 {{{
 $_SERVER['HTTP_HOST']
 }}}
  is set.
 2. Also I've found that in the case of this specific request
 {{{
 $_SERVER['SERVER_NAME']
 }}}
  is defined and not empty and can be used as a replacement.

 My suggestion is to first check if
 {{{
 $_SERVER['HTTP_HOST']
 }}}
 is set else check if
 {{{
 $_SERVER['SERVER_NAME']
 }}}
 is set and if both are not set to implement a graceful error handling.

 This may be related to #34353.

 WP 5.2.2
 PHP 5.6.40
 Server: Apache/2.4.25 (Debian)
 WP_DEBUG = true

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


More information about the wp-trac mailing list