diff options
-rw-r--r-- | includes/block/BlockUtils.php | 7 | ||||
-rw-r--r-- | includes/block/DatabaseBlockStore.php | 3 | ||||
-rw-r--r-- | includes/page/Article.php | 4 | ||||
-rw-r--r-- | tests/phpunit/unit/includes/block/BlockUtilsTest.php | 7 |
4 files changed, 4 insertions, 17 deletions
diff --git a/includes/block/BlockUtils.php b/includes/block/BlockUtils.php index be33d56ebf87..704affefebac 100644 --- a/includes/block/BlockUtils.php +++ b/includes/block/BlockUtils.php @@ -120,13 +120,6 @@ class BlockUtils { return [ IPUtils::sanitizeRange( $target ), AbstractBlock::TYPE_RANGE ]; } - // Consider the possibility that this is not a username at all - // but actually an old subpage (T31797) - if ( str_contains( $target, '/' ) ) { - // An old subpage, drill down to the user behind it - $target = explode( '/', $target )[0]; - } - if ( preg_match( '/^#\d+$/', $target ) ) { // Autoblock reference in the form "#12345" return [ substr( $target, 1 ), AbstractBlock::TYPE_AUTO ]; diff --git a/includes/block/DatabaseBlockStore.php b/includes/block/DatabaseBlockStore.php index 84fcc0f029e2..127b1870f903 100644 --- a/includes/block/DatabaseBlockStore.php +++ b/includes/block/DatabaseBlockStore.php @@ -39,7 +39,6 @@ use MediaWiki\User\UserIdentityValue; use Psr\Log\LoggerInterface; use RuntimeException; use stdClass; -use UnexpectedValueException; use Wikimedia\IPUtils; use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\ILoadBalancer; @@ -469,7 +468,7 @@ class DatabaseBlockStore { break; default: - throw new UnexpectedValueException( "Tried to load block with invalid type" ); + $this->logger->debug( "Ignoring invalid vague target" ); } } diff --git a/includes/page/Article.php b/includes/page/Article.php index 97f4c67b29f9..a6d3e1e30888 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1030,14 +1030,14 @@ class Article implements Page { $ns = $title->getNamespace(); # Don't index user and user talk pages for blocked users (T13443) - if ( ( $ns === NS_USER || $ns === NS_USER_TALK ) && !$title->isSubpage() ) { + if ( $ns === NS_USER || $ns === NS_USER_TALK ) { $specificTarget = null; $vagueTarget = null; $titleText = $title->getText(); if ( IPUtils::isValid( $titleText ) ) { $vagueTarget = $titleText; } else { - $specificTarget = $titleText; + $specificTarget = $title->getRootText(); } if ( $this->blockStore->newFromTarget( $specificTarget, $vagueTarget ) instanceof DatabaseBlock ) { return [ diff --git a/tests/phpunit/unit/includes/block/BlockUtilsTest.php b/tests/phpunit/unit/includes/block/BlockUtilsTest.php index cdbe8120a0c7..fcc4220f7866 100644 --- a/tests/phpunit/unit/includes/block/BlockUtilsTest.php +++ b/tests/phpunit/unit/includes/block/BlockUtilsTest.php @@ -102,14 +102,12 @@ class BlockUtilsTest extends MediaWikiUnitTestCase { /** * @dataProvider provideTestParseBlockTargetNonIpString * @param string $inputTarget - * @param string $baseName if it was a subpage * @param ?UserIdentity $userIdentityLookupResult * @param UserIdentity|string|null $outputTarget * @param ?int $targetType */ public function testParseBlockTargetNonIpString( string $inputTarget, - string $baseName, ?UserIdentity $userIdentityLookupResult, $outputTarget, ?int $targetType @@ -123,7 +121,7 @@ class BlockUtilsTest extends MediaWikiUnitTestCase { $userIdentityLookup = $this->createMock( UserIdentityLookup::class ); $userIdentityLookup ->method( 'getUserIdentityByName' ) - ->with( $baseName ) + ->with( $inputTarget ) ->willReturn( $userIdentityLookupResult ); $blockUtils = $this->getUtils( [], @@ -139,7 +137,6 @@ class BlockUtilsTest extends MediaWikiUnitTestCase { $userIdentity = $this->createMock( UserIdentity::class ); yield 'Name returns a valid user' => [ 'DannyS712', - 'DannyS712', $userIdentity, $userIdentity, AbstractBlock::TYPE_USER @@ -147,7 +144,6 @@ class BlockUtilsTest extends MediaWikiUnitTestCase { yield 'Auto block id' => [ '#123', - '#123', null, '123', AbstractBlock::TYPE_AUTO @@ -155,7 +151,6 @@ class BlockUtilsTest extends MediaWikiUnitTestCase { yield 'Invalid user name, with subpage' => [ 'SomeInvalid#UserName/WithASubpage', - 'SomeInvalid#UserName', null, null, null |