From 74838b2fa2b3ddf79ae734d13d3e937a9697e739 Mon Sep 17 00:00:00 2001 From: Jdlrobson Date: Tue, 11 Aug 2020 15:50:20 +0000 Subject: [PATCH] Revert "ServiceWiring: Avoid usage of deprecated Title::getSubjectPage()" This reverts commit ae8e3ad58b782d3fbcce88366dbb7450df594551. Reason for revert: This led to T260155 as the internal class uses isSubPage which is not available on LinkTarget Bug: T260155 Change-Id: I783f41e70cf1cf3b91737bce9cbf9ac729a778df --- includes/ServiceWiring.php | 3 +-- includes/Skins/SkinUserPageHelper.php | 5 ++--- tests/phpunit/skins/SkinUserPageHelperTest.php | 15 --------------- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 6551bf221..0476abf17 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -84,11 +84,10 @@ return [ $user = $context->getUser(); $userPageHelper = $services->getService( 'Minerva.SkinUserPageHelper' ); $languagesHelper = $services->getService( 'Minerva.LanguagesHelper' ); - $namespaceInfo = $services->getNamespaceInfo(); $relevantUserPageHelper = $title->inNamespace( NS_USER_TALK ) ? new SkinUserPageHelper( - $namespaceInfo->getSubjectPage( $context->getSkin()->getRelevantTitle() ) + $context->getSkin()->getRelevantTitle()->getSubjectPage() ) : $userPageHelper; diff --git a/includes/Skins/SkinUserPageHelper.php b/includes/Skins/SkinUserPageHelper.php index 724f0e7cb..8121b6ce1 100644 --- a/includes/Skins/SkinUserPageHelper.php +++ b/includes/Skins/SkinUserPageHelper.php @@ -20,7 +20,6 @@ namespace MediaWiki\Minerva\Skins; -use MediaWiki\Linker\LinkTarget; use Title; use User; @@ -40,9 +39,9 @@ class SkinUserPageHelper { private $pageUser; /** - * @param Title|LinkTarget|null $title + * @param Title|null $title */ - public function __construct( $title = null ) { + public function __construct( Title $title = null ) { $this->title = $title; } diff --git a/tests/phpunit/skins/SkinUserPageHelperTest.php b/tests/phpunit/skins/SkinUserPageHelperTest.php index 44e7aedd7..f37bdd368 100644 --- a/tests/phpunit/skins/SkinUserPageHelperTest.php +++ b/tests/phpunit/skins/SkinUserPageHelperTest.php @@ -2,7 +2,6 @@ namespace Tests\MediaWiki\Minerva; -use MediaWiki\Linker\LinkTarget; use MediaWiki\Minerva\Skins\SkinUserPageHelper; use MediaWikiTestCase; use Title; @@ -25,20 +24,6 @@ class SkinUserPageHelperTest extends MediaWikiTestCase { $this->assertFalse( $helper->isUserPage() ); } - /** - * @covers ::isUserPage - * @covers ::getPageUser - */ - public function testLinkTargetAsConsumer() { - $linkTarget = $this->createMock( LinkTarget::class ); - $linkTarget->method( 'getText' ) - ->willReturn( 'User:LinkTarget' ); - - $helper = new SkinUserPageHelper( $linkTarget ); - $this->assertNull( $helper->getPageUser() ); - $this->assertFalse( $helper->isUserPage() ); - } - /** * @covers ::isUserPage * @covers ::fetchData