Don't use NamespaceInfo when it's not necessary
Change-Id: Ia568a7d3493ea3f23e58a991dbdbef10ad34fcdb
This commit is contained in:
parent
64b8677ca2
commit
ac47a1a9af
5 changed files with 9 additions and 38 deletions
|
|
@ -490,10 +490,7 @@ class SpecialPageFactory {
|
|||
]
|
||||
],
|
||||
'PasswordPolicies' => [
|
||||
'class' => \SpecialPasswordPolicies::class,
|
||||
'services' => [
|
||||
'NamespaceInfo'
|
||||
]
|
||||
'class' => \SpecialPasswordPolicies::class
|
||||
],
|
||||
|
||||
// Recent changes and logs
|
||||
|
|
@ -629,10 +626,7 @@ class SpecialPageFactory {
|
|||
'class' => \SpecialApiSandbox::class,
|
||||
],
|
||||
'Statistics' => [
|
||||
'class' => \SpecialStatistics::class,
|
||||
'services' => [
|
||||
'NamespaceInfo',
|
||||
]
|
||||
'class' => \SpecialStatistics::class
|
||||
],
|
||||
'Allmessages' => [
|
||||
'class' => \SpecialAllMessages::class,
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class SpecialListGroupRights extends SpecialPage {
|
|||
$groupnameLocalized = UserGroupMembership::getGroupName( $groupname );
|
||||
|
||||
$grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $groupname )
|
||||
?: Title::newFromText( $this->nsInfo->getCanonicalName( NS_PROJECT ) . ':' . $groupname );
|
||||
?: Title::makeTitleSafe( NS_PROJECT, $groupname );
|
||||
|
||||
if ( $group == '*' || !$grouppageLocalizedTitle ) {
|
||||
// Do not make a link for the generic * group or group with invalid group page
|
||||
|
|
|
|||
|
|
@ -30,16 +30,8 @@
|
|||
*/
|
||||
class SpecialPasswordPolicies extends SpecialPage {
|
||||
|
||||
/** @var NamespaceInfo */
|
||||
private $nsInfo;
|
||||
|
||||
/**
|
||||
* @param NamespaceInfo $nsInfo
|
||||
*/
|
||||
public function __construct( NamespaceInfo $nsInfo ) {
|
||||
public function __construct() {
|
||||
parent::__construct( 'PasswordPolicies' );
|
||||
|
||||
$this->nsInfo = $nsInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,9 +85,7 @@ class SpecialPasswordPolicies extends SpecialPage {
|
|||
$groupnameLocalized = UserGroupMembership::getGroupName( $group );
|
||||
|
||||
$grouppageLocalizedTitle = UserGroupMembership::getGroupPage( $group )
|
||||
?: Title::newFromText(
|
||||
$this->nsInfo->getCanonicalName( NS_PROJECT ) . ':' . $group
|
||||
);
|
||||
?: Title::makeTitle( NS_PROJECT, $group );
|
||||
|
||||
$grouppage = $linkRenderer->makeLink(
|
||||
$grouppageLocalizedTitle,
|
||||
|
|
|
|||
|
|
@ -31,15 +31,8 @@ class SpecialStatistics extends SpecialPage {
|
|||
private $edits, $good, $images, $total, $users,
|
||||
$activeUsers = 0;
|
||||
|
||||
/** @var NamespaceInfo */
|
||||
private $nsInfo;
|
||||
|
||||
/**
|
||||
* @param NamespaceInfo $nsInfo
|
||||
*/
|
||||
public function __construct( NamespaceInfo $nsInfo ) {
|
||||
public function __construct() {
|
||||
parent::__construct( 'Statistics' );
|
||||
$this->nsInfo = $nsInfo;
|
||||
}
|
||||
|
||||
public function execute( $par ) {
|
||||
|
|
@ -209,9 +202,7 @@ class SpecialStatistics extends SpecialPage {
|
|||
}
|
||||
$groupnameLocalized = UserGroupMembership::getGroupName( $group );
|
||||
$linkTarget = UserGroupMembership::getGroupPage( $group )
|
||||
?: Title::newFromText(
|
||||
$this->nsInfo->getCanonicalName( NS_PROJECT ) . ':' . $group
|
||||
);
|
||||
?: Title::makeTitleSafe( NS_PROJECT, $group );
|
||||
|
||||
if ( $linkTarget ) {
|
||||
$grouppage = $linkRenderer->makeLink(
|
||||
|
|
|
|||
|
|
@ -23,10 +23,9 @@ class ApiQueryTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public function testTitlesGetNormalized() {
|
||||
global $wgMetaNamespace;
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgCapitalLinks' => true,
|
||||
'wgMetaNamespace' => 'TestWiki',
|
||||
] );
|
||||
|
||||
$data = $this->doApiRequest( [
|
||||
|
|
@ -36,14 +35,11 @@ class ApiQueryTest extends ApiTestCase {
|
|||
$this->assertArrayHasKey( 'query', $data[0] );
|
||||
$this->assertArrayHasKey( 'normalized', $data[0]['query'] );
|
||||
|
||||
// Forge a normalized title
|
||||
$to = Title::newFromText( $wgMetaNamespace . ':ArticleA' );
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'fromencoded' => false,
|
||||
'from' => 'Project:articleA',
|
||||
'to' => $to->getPrefixedText(),
|
||||
'to' => 'TestWiki:ArticleA',
|
||||
],
|
||||
$data[0]['query']['normalized'][0]
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue