From f7cddcf7c178cb90e993fe3690f310ab06f6a846 Mon Sep 17 00:00:00 2001 From: Thalia Date: Wed, 24 Jul 2019 18:17:36 +0100 Subject: [PATCH] Remove deprecated handling of array keys for $wgProxyList Change-Id: Ic9cc2a5585180ab57fd361342cbac8210b094a5c --- RELEASE-NOTES-1.34 | 3 +++ includes/DefaultSettings.php | 5 ++-- includes/block/BlockManager.php | 27 +------------------ .../includes/block/BlockManagerTest.php | 21 --------------- tests/phpunit/includes/user/UserTest.php | 12 --------- 5 files changed, 6 insertions(+), 62 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 7a24818f40..9330d105f4 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -396,6 +396,9 @@ because of Phabricator reports. PermissionManager::getUserPermissions() instead. * The LocalisationCacheRecache hook no longer allows purging of message blobs to be prevented. Modifying the $purgeBlobs parameter now has no effect. +* The use of $wgProxyList with IP addresses in the array keys, deprecated in + 1.30, was removed. Instead, $wgProxyList should be an array with IP addresses + as the values, or a string path to a file containing one IP address per line. === Other changes in 1.34 === * … diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 6a1f7b53c4..d23cc7bf1c 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -6002,9 +6002,8 @@ $wgSecretKey = false; * Big list of banned IP addresses. * * This can have the following formats: - * - An array of addresses, either in the values - * or the keys (for backward compatibility, deprecated since 1.30) - * - A string, in that case this is the path to a file + * - An array of addresses + * - A string, in which case this is the path to a file * containing the list of IP addresses, one per line */ $wgProxyList = []; diff --git a/includes/block/BlockManager.php b/includes/block/BlockManager.php index 68141a178b..c82ed1c258 100644 --- a/includes/block/BlockManager.php +++ b/includes/block/BlockManager.php @@ -293,32 +293,7 @@ class BlockManager { $proxyList = array_map( 'trim', file( $proxyList ) ); } - $resultProxyList = []; - $deprecatedIPEntries = []; - - // backward compatibility: move all ip addresses in keys to values - foreach ( $proxyList as $key => $value ) { - $keyIsIP = IP::isIPAddress( $key ); - $valueIsIP = IP::isIPAddress( $value ); - if ( $keyIsIP && !$valueIsIP ) { - $deprecatedIPEntries[] = $key; - $resultProxyList[] = $key; - } elseif ( $keyIsIP && $valueIsIP ) { - $deprecatedIPEntries[] = $key; - $resultProxyList[] = $key; - $resultProxyList[] = $value; - } else { - $resultProxyList[] = $value; - } - } - - if ( $deprecatedIPEntries ) { - wfDeprecated( - 'IP addresses in the keys of $wgProxyList (found the following IP addresses in keys: ' . - implode( ', ', $deprecatedIPEntries ) . ', please move them to values)', '1.30' ); - } - - $proxyListIPSet = new IPSet( $resultProxyList ); + $proxyListIPSet = new IPSet( $proxyList ); return $proxyListIPSet->match( $ip ); } diff --git a/tests/phpunit/includes/block/BlockManagerTest.php b/tests/phpunit/includes/block/BlockManagerTest.php index b8f60c4e82..f42777c503 100644 --- a/tests/phpunit/includes/block/BlockManagerTest.php +++ b/tests/phpunit/includes/block/BlockManagerTest.php @@ -160,27 +160,6 @@ class BlockManagerTest extends MediaWikiTestCase { ]; } - /** - * @covers ::isLocallyBlockedProxy - */ - public function testIsLocallyBlockedProxyDeprecated() { - $proxy = '1.2.3.4'; - - $this->hideDeprecated( - 'IP addresses in the keys of $wgProxyList (found the following IP ' . - 'addresses in keys: ' . $proxy . ', please move them to values)' - ); - - $blockManager = TestingAccessWrapper::newFromObject( - $this->getBlockManager( [ - 'wgProxyList' => [ $proxy => 'test' ] - ] ) - ); - - $ip = '1.2.3.4'; - $this->assertTrue( $blockManager->isLocallyBlockedProxy( $ip ) ); - } - /** * @dataProvider provideIsDnsBlacklisted * @covers ::isDnsBlacklisted diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index bb723158d6..62e8e2364d 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -1021,18 +1021,6 @@ class UserTest extends MediaWikiTestCase { ] ); $this->assertTrue( User::isLocallyBlockedProxy( $ip ) ); - - $this->hideDeprecated( - 'IP addresses in the keys of $wgProxyList (found the following IP ' . - 'addresses in keys: ' . $blockListEntry . ', please move them to values)' - ); - $this->setMwGlobals( - 'wgProxyList', - [ - $blockListEntry => 'test' - ] - ); - $this->assertTrue( User::isLocallyBlockedProxy( $ip ) ); } /** -- 2.20.1