-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Conversation
getIpAddressFromProxy failed while unit-testing, because there is no REMOTE_ADDR set. Now there is a check to see if it is set before trying to check if it is in the trustedProxies array.
Can you provide a unit test? I don't see any unit test broken in Travis-CI due this thing. |
I will provide a unit test shortly, however, the reason that Travis-CI probably didn't break, is because they (probably) supply a REMOTE_ADDR in the $_SERVER global. |
@AxaliaN Um... I know I do not set |
Try running it on Windows, our entire build failed because there was no check for this ;) I can reproduce it any time, with a simple call to getIpAddress. The code checks if $_SERVER['REMOTE_ADDR'] is in an array, but just assumes this variable is set. Apparently, this isn't the case all of the time, so a check is in order imho. |
Just to make my case a little stronger: I just pushed a commit to remove trailing spaces from the unit test, and Travis fails with this error: There was 1 error:
/home/travis/build/zendframework/zf2/tests/ZendTest/Http/PhpEnvironment/RemoteAddressTest.php:140 Which is the exact same error RemoveAddress.php gives. I will fix my unit test for this, but I hope you understand now how there needs to be a check to see if the REMOTE_ADDR key is available. |
Added a check to see if REMOTE_ADDR has been set.
@AxaliaN To be honest, I'm not terribly concerned about tests not running on Windows; Windows is a very rare platform when it comes to deployment. I'll merge anyways, but I don't see this as critical by any means. |
Added isset check for REMOTE_ADDR
Thanks. It didn't just failf or us on windows, but while building using Jenkins as well. That's why it was critical, at least in our case. |
Added isset check for REMOTE_ADDR
getIpAddressFromProxy failed while unit-testing, because there is no REMOTE_ADDR set. Now there is a check to see if it is set before trying to check if it is in the trustedProxies array.