XF 2.3 Upgrading throws config error

Maa

Active member
Hi,

I have an error when trying to upgrade , which relates to config.php

Please see code:
Code:
An exception occurred: [ErrorException] [E_WARNING] Undefined array key "REMOTE_ADDR" in src/config.php on line 13
#0 src/config.php(13): XF::handlePhpError(2, '[E_WARNING] Und...', '/home/...', 13)
#1 src/XF/App.php(264): require('/home/wj...')
#2 src/XF/Container.php(33): XF\App->XF\{closure}(Object(XF\Container))
#3 src/XF/App.php(3834): XF\Container->offsetGet('config')
#4 src/XF/App.php(2228): XF\App->container('config')
#5 src/XF/Cli/App.php(25): XF\App->setup()
#6 src/XF.php(771): XF\Cli\App->setup(Array)
#7 src/XF/Cli/Runner.php(58): XF::setupApp('XF\\Cli\\App')
#8 cmd.php(17): XF\Cli\Runner->run()
#9 {main}

Line 12 and 13 of config are;
Code:
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; }
$_SERVER["REMOTE_ADDR"] = ( isset($_SERVER["HTTP_X_REAL_IP"]) ? $_SERVER["HTTP_X_REAL_IP"] : $_SERVER["REMOTE_ADDR"] );

Any help would be appreciated.

Thank you
 
Solution
This was resolved by amending the lines to this:

Code:
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}

Amending this, then attempting to upgrade an addon, resolved the issue.

Adding this here for other people that may have similar issue.

Thank you
That code is not a part of the standard config file. must have been added from an addon or manually. Looks like it tries to ID proxy users to their real IP.
That said, not sure why it's throwing that error. it looks syntactically correct and you should be able to over-ride those vars.
 
That code is so that CF/DDOS-Guard can show real IPs for users on the board -- I found the code on XF awhile ago.

So potentially, it could be addon related rather than XF?
 
This was resolved by amending the lines to this:

Code:
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}

Amending this, then attempting to upgrade an addon, resolved the issue.

Adding this here for other people that may have similar issue.

Thank you
 
Solution
Back
Top Bottom