diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -1,6 +1,5 @@ getClientIP() - * needs to return anything but the standard localhost value ('127.0.0.1'), - * the command line script should pass in the desired value via the - * 'REMOTE_ADDR' key. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * A request object. - * - * @param $variables - * (optional) An associative array of variables within - * \Drupal::request()->server that should be replaced. If the special element - * 'url' is provided in this array, it will be used to populate some of the - * server defaults; it should be set to the URL of the current page request, - * excluding any GET request but including the script name - * (e.g., http://www.example.com/mysite/index.php). - * - * @see conf_path() - * @see request_uri() - * @see \Symfony\Component\HttpFoundation\Request::getClientIP() - * - * @todo Replace use of `$_REQUEST` with a Symfony request object. - */ - public static function overrideServerVariables(Request $request, $variables = array()) { - $server_vars = $request->server->all(); - // Allow the provided URL to override any existing values in $_SERVER. - if (isset($variables['url'])) { - $url = parse_url($variables['url']); - if (isset($url['host'])) { - $server_vars['HTTP_HOST'] = $url['host']; - } - if (isset($url['path'])) { - $server_vars['SCRIPT_NAME'] = $url['path']; - } - unset($variables['url']); - } - // Define default values for $_SERVER keys. These will be used if $_SERVER - // does not already define them and no other values are passed in to this - // function. - $defaults = array( - 'HTTP_HOST' => 'localhost', - 'SCRIPT_NAME' => NULL, - 'REMOTE_ADDR' => '127.0.0.1', - 'REQUEST_METHOD' => 'GET', - 'SERVER_NAME' => NULL, - 'SERVER_SOFTWARE' => NULL, - 'HTTP_USER_AGENT' => NULL, - ); - // Replace elements of the $_SERVER array, as appropriate. - $request->server->replace($variables + $server_vars + $defaults); - - // @todo remove once conf_path() no longer uses $_SERVER. - $_SERVER = $request->server->all(); - } - }