Page MenuHomePhabricator

$_SERVER stuff from the preamble is getting overwritten in PhabricatorStartup
Closed, ResolvedPublic

Description

We advise writing to $_SERVER in the preamble, but end up overwriting settings in PhabricatorStartup. We should find a way to let users set REMOTE_ADDR and HTTPS without having them overwritten.

Revisions and Commits

Restricted Differential Revision

Event Timeline

epriestley raised the priority of this task from to Normal.
epriestley updated the task description. (Show Details)
epriestley added a project: Setup.
epriestley added a subscriber: epriestley.

See IRC for some more context.

Since this issue doesn't seem like a priority and i am in need of this feature, i would like to propose a possible solution:

Using php's $GLOBALS you could set those values in say $GLOBALS['PREAMBLE']['SERVER'] inside the preamble script and have PhabricatorStartup::normalizeInput merge them into $_SERVER after filtering happened.
This obviously means that the preamble script has to be configured using $GLOBALS, instead of setting $_SERVER directly.

Example (inside preamble.php):

<?php

$GLOBALS['PREAMBLE'] = array (
  'SERVER' => array (
    'REMOTE_ADDR' => $_SERVER['HTTP_X_FORWARDED_FOR'],
    'HTTPS' => true,
  ),
);

I tested it on my phabricator instance and it seemed to have worked, though me not being a php programmer might mean that i overlooked some things. ;)

Will attach a diff for review!

theascone added a revision: Restricted Differential Revision.May 22 2015, 6:50 PM
epriestley added a revision: Restricted Differential Revision.Jun 4 2015, 6:59 PM
epriestley closed this task as Resolved by committing Restricted Diffusion Commit.Jun 5 2015, 12:27 AM
epriestley added a commit: Restricted Diffusion Commit.