Remove hard deprecated old SpecialPageFactory
Bug: T246141 Change-Id: I758fabccdc74ba9a20a3669643d5fffacc244116
This commit is contained in:
parent
ac66469a6d
commit
f7932710ac
5 changed files with 25 additions and 135 deletions
|
|
@ -84,6 +84,7 @@ because of Phabricator reports.
|
|||
* Multiple methods that fell back to the $wgUser global variable were
|
||||
individually hard deprecated previously. The following have now been removed:
|
||||
- ApiTestCase::doLogin
|
||||
- All methods of the old SpecialPageFactory; the entire class was removed
|
||||
* The global function `wfWaitForSlaves`, deprecated since 1.27 & hard-deprecated
|
||||
since 1.35, has been removed. Use LBFactory::waitForReplication() instead.
|
||||
* The support for IE8 has been dropped.
|
||||
|
|
|
|||
|
|
@ -1567,7 +1567,6 @@ $wgAutoloadLocalClasses = [
|
|||
'SpecialPage' => __DIR__ . '/includes/specialpage/SpecialPage.php',
|
||||
'SpecialPageAction' => __DIR__ . '/includes/actions/SpecialPageAction.php',
|
||||
'SpecialPageData' => __DIR__ . '/includes/specials/SpecialPageData.php',
|
||||
'SpecialPageFactory' => __DIR__ . '/includes/specialpage/SpecialPageFactory_deprecated.php',
|
||||
'SpecialPageHistory' => __DIR__ . '/includes/specials/SpecialPageHistory.php',
|
||||
'SpecialPageInfo' => __DIR__ . '/includes/specials/SpecialPageInfo.php',
|
||||
'SpecialPageLanguage' => __DIR__ . '/includes/specials/SpecialPageLanguage.php',
|
||||
|
|
|
|||
|
|
@ -1,108 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Factory for handling the special page list and generating SpecialPage objects.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @ingroup SpecialPage
|
||||
* @defgroup SpecialPage SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
// phpcs:disable MediaWiki.Files.ClassMatchesFilename.NotMatch
|
||||
/**
|
||||
* Wrapper for backward compatibility for old callers that used static methods.
|
||||
*
|
||||
* @deprecated since 1.32, use the SpecialPageFactory service instead
|
||||
*/
|
||||
class SpecialPageFactory {
|
||||
public static function getNames() : array {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->getNames();
|
||||
}
|
||||
|
||||
public static function resolveAlias( $alias ) : array {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->resolveAlias( $alias );
|
||||
}
|
||||
|
||||
public static function exists( $name ) {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->exists( $name );
|
||||
}
|
||||
|
||||
public static function getPage( $name ) {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->getPage( $name );
|
||||
}
|
||||
|
||||
public static function getUsablePages( User $user = null ) : array {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
global $wgUser;
|
||||
$user = $user ?? $wgUser;
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->getUsablePages( $user );
|
||||
}
|
||||
|
||||
public static function getRegularPages() : array {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->getRegularPages();
|
||||
}
|
||||
|
||||
public static function getRestrictedPages( User $user = null ) : array {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
global $wgUser;
|
||||
$user = $user ?? $wgUser;
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()->getRestrictedPages( $user );
|
||||
}
|
||||
|
||||
public static function executePath( Title &$title, IContextSource &$context, $including = false,
|
||||
LinkRenderer $linkRenderer = null
|
||||
) {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()
|
||||
->executePath( $title, $context, $including, $linkRenderer );
|
||||
}
|
||||
|
||||
public static function capturePath(
|
||||
Title $title, IContextSource $context, LinkRenderer $linkRenderer = null
|
||||
) {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()
|
||||
->capturePath( $title, $context, $linkRenderer );
|
||||
}
|
||||
|
||||
public static function getLocalNameFor( $name, $subpage = false ) {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()
|
||||
->getLocalNameFor( $name, $subpage );
|
||||
}
|
||||
|
||||
public static function getTitleForAlias( $alias ) {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory()
|
||||
->getTitleForAlias( $alias );
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op since 1.32, call overrideMwServices() instead
|
||||
*/
|
||||
public static function resetList() {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ class ExtraParserTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
/**
|
||||
* @covers Parser::braceSubstitution
|
||||
* @covers SpecialPageFactory::capturePath
|
||||
* @covers \MediaWiki\SpecialPage\SpecialPageFactory::capturePath
|
||||
*/
|
||||
public function testSpecialPageTransclusionRestoresGlobalState() {
|
||||
$text = "{{Special:ApiHelp/help}}";
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ use Wikimedia\TestingAccessWrapper;
|
|||
* @group SpecialPage
|
||||
*/
|
||||
class SpecialPageFactoryTest extends MediaWikiIntegrationTestCase {
|
||||
private function getFactory() {
|
||||
return MediaWikiServices::getInstance()->getSpecialPageFactory();
|
||||
}
|
||||
|
||||
public function testHookNotCalledTwice() {
|
||||
$count = 0;
|
||||
$this->mergeMwGlobalArrayValue( 'wgHooks', [
|
||||
|
|
@ -70,63 +74,59 @@ class SpecialPageFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers SpecialPageFactory::getPage
|
||||
* @covers \MediaWiki\SpecialPage\SpecialPageFactory::getPage
|
||||
* @dataProvider specialPageProvider
|
||||
*/
|
||||
public function testGetPage( $spec, $shouldReuseInstance ) {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::getPage' );
|
||||
$this->mergeMwGlobalArrayValue( 'wgSpecialPages', [ 'testdummy' => $spec ] );
|
||||
|
||||
$page = SpecialPageFactory::getPage( 'testdummy' );
|
||||
$factory = $this->getFactory();
|
||||
$page = $factory->getPage( 'testdummy' );
|
||||
$this->assertInstanceOf( SpecialPage::class, $page );
|
||||
|
||||
$page2 = SpecialPageFactory::getPage( 'testdummy' );
|
||||
$page2 = $factory->getPage( 'testdummy' );
|
||||
$this->assertEquals( $shouldReuseInstance, $page2 === $page, "Should re-use instance:" );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SpecialPageFactory::getNames
|
||||
* @covers \MediaWiki\SpecialPage\SpecialPageFactory::getNames
|
||||
*/
|
||||
public function testGetNames() {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::getNames' );
|
||||
$this->mergeMwGlobalArrayValue( 'wgSpecialPages', [ 'testdummy' => SpecialAllPages::class ] );
|
||||
|
||||
$names = SpecialPageFactory::getNames();
|
||||
$names = $this->getFactory()->getNames();
|
||||
$this->assertIsArray( $names );
|
||||
$this->assertContains( 'testdummy', $names );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SpecialPageFactory::resolveAlias
|
||||
* @covers \MediaWiki\SpecialPage\SpecialPageFactory::resolveAlias
|
||||
*/
|
||||
public function testResolveAlias() {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::resolveAlias' );
|
||||
$this->setContentLang( 'de' );
|
||||
|
||||
list( $name, $param ) = SpecialPageFactory::resolveAlias( 'Spezialseiten/Foo' );
|
||||
list( $name, $param ) = $this->getFactory()->resolveAlias( 'Spezialseiten/Foo' );
|
||||
$this->assertEquals( 'Specialpages', $name );
|
||||
$this->assertEquals( 'Foo', $param );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SpecialPageFactory::getLocalNameFor
|
||||
* @covers \MediaWiki\SpecialPage\SpecialPageFactory::getLocalNameFor
|
||||
*/
|
||||
public function testGetLocalNameFor() {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::getLocalNameFor' );
|
||||
$this->setContentLang( 'de' );
|
||||
|
||||
$name = SpecialPageFactory::getLocalNameFor( 'Specialpages', 'Foo' );
|
||||
$name = $this->getFactory()->getLocalNameFor( 'Specialpages', 'Foo' );
|
||||
$this->assertEquals( 'Spezialseiten/Foo', $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers SpecialPageFactory::getTitleForAlias
|
||||
* @covers \MediaWiki\SpecialPage\SpecialPageFactory::getTitleForAlias
|
||||
*/
|
||||
public function testGetTitleForAlias() {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::getTitleForAlias' );
|
||||
$this->setContentLang( 'de' );
|
||||
|
||||
$title = SpecialPageFactory::getTitleForAlias( 'Specialpages/Foo' );
|
||||
$title = $this->getFactory()->getTitleForAlias( 'Specialpages/Foo' );
|
||||
$this->assertEquals( 'Spezialseiten/Foo', $title->getText() );
|
||||
$this->assertEquals( NS_SPECIAL, $title->getNamespace() );
|
||||
}
|
||||
|
|
@ -137,8 +137,6 @@ class SpecialPageFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
public function testConflictResolution(
|
||||
$test, $aliasesList, $alias, $expectedName, $expectedAlias, $expectWarnings
|
||||
) {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::resolveAlias' );
|
||||
$this->hideDeprecated( 'SpecialPageFactory::getLocalNameFor' );
|
||||
$lang = clone MediaWikiServices::getInstance()->getContentLanguage();
|
||||
$wrappedLang = TestingAccessWrapper::newFromObject( $lang );
|
||||
$wrappedLang->mExtendedSpecialPageAliases = $aliasesList;
|
||||
|
|
@ -161,9 +159,9 @@ class SpecialPageFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
} );
|
||||
$reset = new ScopedCallback( 'restore_error_handler' );
|
||||
|
||||
list( $name, /*...*/ ) = SpecialPageFactory::resolveAlias( $alias );
|
||||
list( $name, /*...*/ ) = $this->getFactory()->resolveAlias( $alias );
|
||||
$this->assertEquals( $expectedName, $name, "$test: Alias to name" );
|
||||
$result = SpecialPageFactory::getLocalNameFor( $name );
|
||||
$result = $this->getFactory()->getLocalNameFor( $name );
|
||||
$this->assertEquals( $expectedAlias, $result, "$test: Alias to name to alias" );
|
||||
|
||||
$gotWarnings = count( $warnings );
|
||||
|
|
@ -264,17 +262,18 @@ class SpecialPageFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
public function testGetAliasListRecursion() {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::getLocalNameFor' );
|
||||
$called = false;
|
||||
$this->mergeMwGlobalArrayValue( 'wgHooks', [
|
||||
'SpecialPage_initList' => [
|
||||
function () use ( &$called ) {
|
||||
SpecialPageFactory::getLocalNameFor( 'Specialpages' );
|
||||
MediaWikiServices::getInstance()
|
||||
->getSpecialPageFactory()
|
||||
->getLocalNameFor( 'Specialpages' );
|
||||
$called = true;
|
||||
}
|
||||
],
|
||||
] );
|
||||
SpecialPageFactory::getLocalNameFor( 'Specialpages' );
|
||||
$this->getFactory()->getLocalNameFor( 'Specialpages' );
|
||||
$this->assertTrue( $called, 'Recursive call succeeded' );
|
||||
}
|
||||
|
||||
|
|
@ -282,7 +281,6 @@ class SpecialPageFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers \MediaWiki\SpecialPage\SpecialPageFactory::getPage
|
||||
*/
|
||||
public function testSpecialPageCreationThatRequiresService() {
|
||||
$this->hideDeprecated( 'SpecialPageFactory::getPage' );
|
||||
$type = null;
|
||||
|
||||
$this->setMwGlobals( 'wgSpecialPages',
|
||||
|
|
@ -300,7 +298,7 @@ class SpecialPageFactoryTest extends MediaWikiIntegrationTestCase {
|
|||
] ]
|
||||
);
|
||||
|
||||
SpecialPageFactory::getPage( 'TestPage' );
|
||||
$this->getFactory()->getPage( 'TestPage' );
|
||||
|
||||
$this->assertEquals( \MediaWiki\SpecialPage\SpecialPageFactory::class, $type );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue