* wfGetIP() now support resetting its internal static variable. Thanks to
Platonides which introduced this trick with r92960.
* Various tests for $_SERVER['REMOTE_ADDR'] and $wgCommandLineMode.
revert r94575:
- reenable testGetFromServerRemoteAddr() which was not an issue
reintroduce r94558:
- per CR on r94558 by Aaron use meaningful parameter to wfGetIP() when
resetting the static variable ( 'reset' instead of true).
- keep testLackOfRemoteAddrThrowAnException() test in the broken group
with a comment for later fixing.
TODO:
- implements tests for XFF headers.
TEST PLAN:
$ ./phpunit.php --filter wfGetIP --testdox
PHPUnit 3.5.14 by Sebastian Bergmann.
wfGetIP
[x] Get loopback address when in command line
[x] Get from server remote addr
[x] Lack of remote addr throw an exception
$
- reverts ./includes/ProxyTools.php
- marks tests broken
In our test suite, the first call to wfGetIP() set the static variable.
Hence the remaining of the code is only tested on the first call to it.
Resetting the static variable enlight a bug somewhere in our code where
we are calling wfGetIP() but can not reliably get an IP, somehow REMOTE_ADDR
does not exist and $wgCommandLineMode is disabled.
Will have to track this bug further when I got time.
* wfGetIP() now support resetting its internal static variable. Thanks to
Platonides which introduced this trick with r92960.
* Various tests for $_SERVER['REMOTE_ADDR'] and $wgCommandLineMode.
TODO:
- implements tests for XFF headers.
TEST PLAN:
$ ./phpunit.php --filter wfGetIP --testdox
PHPUnit 3.5.14 by Sebastian Bergmann.
wfGetIP
[x] Get loopback address when in command line
[x] Get from server remote addr
[x] Lack of remote addr throw an exception
$
* declare $ip and $ipchain so that it doesn't throw notices and warnings
* don't set $ip to false after getting it from $_SERVER['REMOTE_ADDR'], otherwise it won't work when there's no XFF header
* fix logic when throwing the exception: throw it when there's no IP
Doesn't seem like a proper fix here... At best, this'll be dumping random crap to some random file unless the user has a local copy of the /dev/null device file, which seems.... wrong. :)
For anything generating command lines, it probably won't make any difference (assuming exec() is enabled at all!) since open_basedir won't be searching through the command line (I think).
Assuming the core use case actually happens (open_basedir is set, but proc_open() is available to run tidy), a more correct fix is probably to go ahead and read in stderr and toss the results, or maybe better pass it through to PHP's stderr FD instead of opening /dev/null ourselves. Tidy has a -q option which should suppress random "hi i'm tidy version XYZ" if it's currently present.
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
and HAS NO FUCKING DOCUMENTATION
and CAUSES ERRORS AND FAILURES
This quick hack should make it appear to basically work, assuming it does anything useful at all.
wfGetClientIPfromXFF() uses undeclared variables -- it will never return a non-null value, but will in most cases trigger PHP notices about accessing unused variables.
It's also not documented as to what it does or how it's supposed to differ from the functions above it.
Please document, rewrite, and test this function if it is required.