Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-27796

$_REQUEST['HTTP_HOST'] not set

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.3
    • Fix Version/s: 2.1.1
    • Component/s: Administration
    • Labels:
    • Environment:
      Apache, virtualhosts, RHEL5 to be specific.
    • Database:
      Any
    • Testing Instructions:
      Hide

      Configure apache somehow to not populate HTTP_HOST (not really sure how our vhost setup did that...)

      or use good old telnet and type HTTP 1.0 style GET request

      Show
      Configure apache somehow to not populate HTTP_HOST (not really sure how our vhost setup did that...) or use good old telnet and type HTTP 1.0 style GET request
    • Workaround:
      Hide

      I should think http://php.net/parse_url and $_SERVER['PHP_SELF'] would be better than hand-rolling all this, but perhaps PHP_SELF is not consistently populated either...

      So just fixing the immediate buglet:

      This patch is un-tested, actually. The array() might need to be array('host'=>null) instead.

      Index: setuplib.php
      ===================================================================
      — setuplib.php (revision 5)
      +++ setuplib.php (working copy)
      @@ -725,7 +725,7 @@
      */
      function setup_get_remote_url() {
      $rurl = array();

      • list($rurl['host']) = explode(':', $_SERVER['HTTP_HOST']);
        + list($rurl['host']) = isset($_SERVER['HTTP_HOST']) ? explode(':', $_SERVER['HTTP_HOST']) : array();
        $rurl['port'] = $_SERVER['SERVER_PORT'];
        $rurl['path'] = $_SERVER['SCRIPT_NAME']; // Script path without slash arguments
        $rurl['scheme'] = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] === 'off' or $_SERVER['HTTPS'] === 'Off' or $_SERVER['HTTPS'] === 'OFF') ? 'http' : 'https';
      Show
      I should think http://php.net/parse_url and $_SERVER ['PHP_SELF'] would be better than hand-rolling all this, but perhaps PHP_SELF is not consistently populated either... So just fixing the immediate buglet: This patch is un-tested, actually. The array() might need to be array('host'=>null) instead. Index: setuplib.php =================================================================== — setuplib.php (revision 5) +++ setuplib.php (working copy) @@ -725,7 +725,7 @@ */ function setup_get_remote_url() { $rurl = array(); list($rurl ['host'] ) = explode(':', $_SERVER ['HTTP_HOST'] ); + list($rurl ['host'] ) = isset($_SERVER ['HTTP_HOST'] ) ? explode(':', $_SERVER ['HTTP_HOST'] ) : array(); $rurl ['port'] = $_SERVER ['SERVER_PORT'] ; $rurl ['path'] = $_SERVER ['SCRIPT_NAME'] ; // Script path without slash arguments $rurl ['scheme'] = (empty($_SERVER ['HTTPS'] ) or $_SERVER ['HTTPS'] === 'off' or $_SERVER ['HTTPS'] === 'Off' or $_SERVER ['HTTPS'] === 'OFF') ? 'http' : 'https';
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w29_MDL-27796_m22_httphost

      Description

      PHP Notice: Undefined index: HTTP_HOST in /var/www/html/example.com/moodle_versions/r5/lib/setuplib.php on line 728

      Moodle seems to function just fine without the 'host' setting so far, so this is just an annoyance in the logs to us.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  1/Aug/11