Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312161

Change subject: Use the ProxyLookup service if possible
......................................................................

Use the ProxyLookup service if possible

Change-Id: Ic2b585834887364cbf08e4fca3bb8e9a96630207
---
M CheckUser.hooks.php
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CheckUser 
refs/changes/61/312161/1

diff --git a/CheckUser.hooks.php b/CheckUser.hooks.php
index 9c812d4..b85610d 100755
--- a/CheckUser.hooks.php
+++ b/CheckUser.hooks.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\MediaWikiServices;
+
 class CheckUserHooks {
        /**
         * Hook function for RecentChange_save
@@ -297,6 +300,12 @@
                $ipchain = array_map( 'trim', explode( ',', $xff ) );
                $ipchain = array_reverse( $ipchain );
 
+               if ( class_exists( ProxyLookup::class ) ) { // MW 1.28+
+                       $isConfigured = [ 
MediaWikiServices::getInstance()->getProxyLookup(), 'isConfiguredProxy' ];
+               } else {
+                       $isConfigured = [ IP::class, 'isConfiguredProxy' ];
+               }
+
                $client = null; // best guess of the client IP
                $isSquidOnly = false; // all proxy servers where site 
Squid/Varnish servers?
                # Step through XFF list and find the last address in the list 
which is a
@@ -308,7 +317,7 @@
                        if ( $curIP === null ) {
                                break; // not a valid IP address
                        }
-                       $curIsSquid = IP::isConfiguredProxy( $curIP );
+                       $curIsSquid = call_user_func( $isConfigured, $curIP );
                        if ( $client === null ) {
                                $client = $curIP;
                                $isSquidOnly = $curIsSquid;

-- 
To view, visit https://gerrit.wikimedia.org/r/312161
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2b585834887364cbf08e4fca3bb8e9a96630207
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CheckUser
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to