http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72803
Revision: 72803
Author: platonides
Date: 2010-09-11 13:45:51 +0000 (Sat, 11 Sep 2010)
Log Message:
-----------
Remove $wgIP global, but add a hook instead.
This allows extensions to "make mediawiki ignore ips completely", as requested
earlier today in #mediawiki
Modified Paths:
--------------
trunk/phase3/docs/hooks.txt
trunk/phase3/includes/ProxyTools.php
trunk/phase3/includes/Setup.php
Modified: trunk/phase3/docs/hooks.txt
===================================================================
--- trunk/phase3/docs/hooks.txt 2010-09-11 13:04:06 UTC (rev 72802)
+++ trunk/phase3/docs/hooks.txt 2010-09-11 13:45:51 UTC (rev 72803)
@@ -826,6 +826,9 @@
$url: string value as output (out parameter, can modify)
$query: query options passed to Title::getInternalURL()
+'GetIP': modify the ip of the current user (called only once)
+&$ip: string holding the ip as determined so far
+
'GetLinkColours': modify the CSS class of an array of page links
$linkcolour_ids: array of prefixed DB keys of the pages linked to,
indexed by page_id.
Modified: trunk/phase3/includes/ProxyTools.php
===================================================================
--- trunk/phase3/includes/ProxyTools.php 2010-09-11 13:04:06 UTC (rev
72802)
+++ trunk/phase3/includes/ProxyTools.php 2010-09-11 13:45:51 UTC (rev
72803)
@@ -68,15 +68,15 @@
* @return string
*/
function wfGetIP() {
- global $wgIP, $wgUsePrivateIPs, $wgCommandLineMode;
+ global $wgUsePrivateIPs, $wgCommandLineMode;
+ static $ip = false;
# Return cached result
- if ( !empty( $wgIP ) ) {
- return $wgIP;
+ if ( !empty( $ip ) ) {
+ return $ip;
}
$ipchain = array();
- $ip = false;
/* collect the originating ips */
# Client connecting to this webserver
@@ -112,12 +112,14 @@
}
}
+ # Allow extensions to improve our guess
+ wfRunHooks( 'GetIP', array( &$ip ) );
+
if( !$ip ) {
throw new MWException( "Unable to determine IP" );
}
wfDebug( "IP: $ip\n" );
- $wgIP = $ip;
return $ip;
}
Modified: trunk/phase3/includes/Setup.php
===================================================================
--- trunk/phase3/includes/Setup.php 2010-09-11 13:04:06 UTC (rev 72802)
+++ trunk/phase3/includes/Setup.php 2010-09-11 13:45:51 UTC (rev 72803)
@@ -182,7 +182,6 @@
date_default_timezone_set( date_default_timezone_get() );
wfRestoreWarnings();
-$wgIP = false; # Load on demand
# Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
$wgRequest = new WebRequest;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs