jenkins-bot has submitted this change and it was merged. Change subject: Workaround ip2long limitation ......................................................................
Workaround ip2long limitation * This was resulting in bogus queries that did ipblock table scans bug: 60035 Change-Id: Id8f8846e002abcc0010c8706c664db86257786bf --- M includes/utils/IP.php M tests/phpunit/includes/utils/IPTest.php 2 files changed, 4 insertions(+), 0 deletions(-) Approvals: BryanDavis: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/utils/IP.php b/includes/utils/IP.php index 2686e11..871f71b 100644 --- a/includes/utils/IP.php +++ b/includes/utils/IP.php @@ -489,6 +489,8 @@ if ( self::isIPv6( $ip ) ) { $n = self::toUnsigned6( $ip ); } else { + // Bug 60035: an IP with leading 0's fails in ip2long sometimes (e.g. *.08) + $ip = preg_replace( '/(?<=\.)0+(?=[1-9])/', '', $ip ); $n = ip2long( $ip ); if ( $n < 0 ) { $n += pow( 2, 32 ); diff --git a/tests/phpunit/includes/utils/IPTest.php b/tests/phpunit/includes/utils/IPTest.php index 24b077a..1267268 100644 --- a/tests/phpunit/includes/utils/IPTest.php +++ b/tests/phpunit/includes/utils/IPTest.php @@ -297,6 +297,8 @@ array( 16909060, '1.2.3.4' ), array( 2130706433, '127.0.0.1' ), array( '2147483648', '128.0.0.0' ), + array( 2130706440, '127.0.0.08' ), + array( 2130706441, '127.0.0.09' ), array( '3735931646', '222.173.202.254' ), array( pow( 2, 32 ) - 1, '255.255.255.255' ), array( false, 'IN.VA.LI.D' ), -- To view, visit https://gerrit.wikimedia.org/r/107543 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id8f8846e002abcc0010c8706c664db86257786bf Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits