diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 43cde80af..b810f0e08 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -155,9 +155,7 @@ return [ }, 'Minerva.SkinOptions' => static function ( MediaWikiServices $services ): SkinOptions { return new SkinOptions( - $services->getHookContainer(), - $services->getUserFactory(), - $services->getUserNameUtils() + $services->getHookContainer() ); }, 'Minerva.Permissions' => static function ( MediaWikiServices $services ): IMinervaPagePermissions { diff --git a/includes/SkinOptions.php b/includes/SkinOptions.php index 32bda71e7..022336298 100644 --- a/includes/SkinOptions.php +++ b/includes/SkinOptions.php @@ -23,9 +23,6 @@ use MediaWiki\HookContainer\HookContainer; use MediaWiki\MediaWikiServices; use MediaWiki\Minerva\Hooks\HookRunner; use MediaWiki\Minerva\Skins\SkinMinerva; -use MediaWiki\Minerva\Skins\SkinUserPageHelper; -use MediaWiki\User\UserFactory; -use MediaWiki\User\UserNameUtils; use MobileContext; use Skin; @@ -84,17 +81,11 @@ final class SkinOptions { ]; private HookContainer $hookContainer; - private UserFactory $userFactory; - private UserNameUtils $userNameUtils; public function __construct( - HookContainer $hookContainer, - UserFactory $userFactory, - UserNameUtils $userNameUtils + HookContainer $hookContainer ) { $this->hookContainer = $hookContainer; - $this->userFactory = $userFactory; - $this->userNameUtils = $userNameUtils; } /** @@ -166,14 +157,7 @@ final class SkinOptions { if ( $title !== null ) { // T232653: TALK_AT_TOP, HISTORY_IN_PAGE_ACTIONS, TOOLBAR_SUBMENU should // be true on user pages and user talk pages for all users - // - // For some reason using $services->getService( 'SkinUserPageHelper' ) - // here results in a circular dependency error which is why - // SkinUserPageHelper is being instantiated instead. - $relevantUserPageHelper = ( new SkinUserPageHelper( - $this->userFactory, - $this->userNameUtils - ) ) + $relevantUserPageHelper = $services->getService( 'Minerva.SkinUserPageHelper' ) ->setContext( $mobileContext ) ->setTitle( $title->inNamespace( NS_USER_TALK ) ? $title->getSubjectPage() : $title diff --git a/tests/phpunit/permissions/MinervaPagePermissionsTest.php b/tests/phpunit/permissions/MinervaPagePermissionsTest.php index 87eb22f47..d017611d6 100644 --- a/tests/phpunit/permissions/MinervaPagePermissionsTest.php +++ b/tests/phpunit/permissions/MinervaPagePermissionsTest.php @@ -12,7 +12,6 @@ use MediaWiki\Permissions\Authority; use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait; use MediaWiki\Title\Title; use MediaWiki\User\UserFactory; -use MediaWiki\User\UserNameUtils; use MediaWiki\Watchlist\WatchlistManager; use MediaWikiIntegrationTestCase; use RequestContext; @@ -45,9 +44,7 @@ class MinervaPagePermissionsTest extends MediaWikiIntegrationTestCase { $contentHandler = $contentHandler ?? $this->getMockForAbstractClass( ContentHandler::class, [], '', false ); $skinOptions = new SkinOptions( - $this->createMock( HookContainer::class ), - $this->createMock( UserFactory::class ), - $this->createMock( UserNameUtils::class ) + $this->createMock( HookContainer::class ) ); if ( $options ) { $skinOptions->setMultiple( $options ); diff --git a/tests/phpunit/skins/SkinMinervaTest.php b/tests/phpunit/skins/SkinMinervaTest.php index 8c85b461f..1b23f7183 100644 --- a/tests/phpunit/skins/SkinMinervaTest.php +++ b/tests/phpunit/skins/SkinMinervaTest.php @@ -56,9 +56,7 @@ class SkinMinervaTest extends MediaWikiIntegrationTestCase { private function overrideSkinOptions( $options ) { $services = $this->getServiceContainer(); $mockOptions = new SkinOptions( - $services->getHookContainer(), - $services->getUserFactory(), - $services->getUserNameUtils() + $services->getHookContainer() ); $mockOptions->setMultiple( $options ); $this->setService( 'Minerva.SkinOptions', $mockOptions ); diff --git a/tests/phpunit/unit/SkinOptionsTest.php b/tests/phpunit/unit/SkinOptionsTest.php index 67d74df02..d96d76217 100644 --- a/tests/phpunit/unit/SkinOptionsTest.php +++ b/tests/phpunit/unit/SkinOptionsTest.php @@ -3,8 +3,6 @@ namespace MediaWiki\Minerva; use MediaWiki\HookContainer\HookContainer; -use MediaWiki\User\UserFactory; -use MediaWiki\User\UserNameUtils; use MediaWikiUnitTestCase; use OutOfBoundsException; @@ -17,9 +15,7 @@ class SkinOptionsTest extends MediaWikiUnitTestCase { private function newSkinOptions() { return new SkinOptions( - $this->createMock( HookContainer::class ), - $this->createMock( UserFactory::class ), - $this->createMock( UserNameUtils::class ) + $this->createMock( HookContainer::class ) ); }