Use service 'Minerva.SkinUserPageHelper' in SkinOptions

Change-Id: I014e61c6692adbbe449f1e6aa9c6ae73dbcff925
This commit is contained in:
Fomafix 2024-03-24 10:36:58 +00:00
parent 7ea5db0344
commit 0adbe80280
5 changed files with 6 additions and 33 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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 );

View file

@ -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 );

View file

@ -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 )
);
}