Title: Use TitleArrayFromResult instead of TitleArray
TitleArray is just a tiny little wrapper to TitleArrayFromResult, so use the latter instead of the former. I have plans of killing the former soon. Change-Id: Ia06a6bb370ce313f38d3ec9a221ed7296aec0ee2
This commit is contained in:
parent
9b093ffe44
commit
a99ec1b4fa
10 changed files with 30 additions and 24 deletions
|
|
@ -789,6 +789,8 @@ because of Phabricator reports.
|
|||
the handler are deprecated and will soon be removed. Deprecated ways to
|
||||
specify a hook handler include callables wrapped in an array. Handlers
|
||||
defined using a "HookHandlers" entry in extension.json are not affected.
|
||||
* TitleArray::newFromResult() has been deprecated and now emits deprecation
|
||||
warnings, use TitleArrayFromResults instead.
|
||||
* The MediaWikiIntegrationTestCase::$users has been deprecated. Use Authority
|
||||
if possible, or call ::getTestUser() or ::getTestSysop() directly.
|
||||
* The tests/phpunit/phpunit.php entrypoint has been deprecated. PHPUnit
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use DeferredUpdates;
|
|||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\PageIdentity;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\Title\TitleArray;
|
||||
use MediaWiki\Title\TitleArrayFromResult;
|
||||
use MWException;
|
||||
use stdClass;
|
||||
use Wikimedia\Rdbms\IConnectionProvider;
|
||||
|
|
@ -320,7 +320,7 @@ class Category {
|
|||
* category sort key $offset.
|
||||
* @param int|false $limit
|
||||
* @param string $offset
|
||||
* @return TitleArray TitleArray object for category members.
|
||||
* @return TitleArrayFromResult Title objects for category members.
|
||||
*/
|
||||
public function getMembers( $limit = false, $offset = '' ) {
|
||||
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||
|
|
@ -340,7 +340,7 @@ class Category {
|
|||
$queryBuilder->andWhere( $dbr->buildComparison( '>', [ 'cl_sortkey' => $offset ] ) );
|
||||
}
|
||||
|
||||
$result = TitleArray::newFromResult( $queryBuilder->caller( __METHOD__ )->fetchResultSet() );
|
||||
$result = new TitleArrayFromResult( $queryBuilder->caller( __METHOD__ )->fetchResultSet() );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use MediaWiki\MainConfigNames;
|
|||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\PageReference;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\Title\TitleArray;
|
||||
use MediaWiki\Title\TitleArrayFromResult;
|
||||
|
||||
/**
|
||||
* Job to purge the HTML/file cache for all pages that link to or use another page or file
|
||||
|
|
@ -165,7 +165,7 @@ class HTMLCacheUpdateJob extends Job {
|
|||
if ( $config->get( MainConfigNames::PageLanguageUseDB ) ) {
|
||||
$queryBuilder->field( 'page_lang' );
|
||||
}
|
||||
$titleArray = TitleArray::newFromResult( $queryBuilder->caller( __METHOD__ )->fetchResultSet() );
|
||||
$titleArray = new TitleArrayFromResult( $queryBuilder->caller( __METHOD__ )->fetchResultSet() );
|
||||
|
||||
// Update CDN and file caches
|
||||
$htmlCache = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
use MediaWiki\Actions\FileDeleteAction;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\Title\TitleArray;
|
||||
use MediaWiki\Title\TitleArrayFromResult;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
|
||||
/**
|
||||
|
|
@ -218,7 +218,7 @@ class WikiFilePage extends WikiPage {
|
|||
* For foreign API files (InstantCommons), this is not supported currently.
|
||||
* Results will include hidden categories.
|
||||
*
|
||||
* @return TitleArray|Title[]
|
||||
* @return TitleArrayFromResult
|
||||
* @since 1.23
|
||||
*/
|
||||
public function getForeignCategories() {
|
||||
|
|
@ -228,7 +228,7 @@ class WikiFilePage extends WikiPage {
|
|||
|
||||
if ( !$file instanceof LocalFile ) {
|
||||
wfDebug( __METHOD__ . " is not supported for this file" );
|
||||
return TitleArray::newFromResult( new FakeResultWrapper( [] ) );
|
||||
return new TitleArrayFromResult( new FakeResultWrapper( [] ) );
|
||||
}
|
||||
|
||||
/** @var LocalRepo $repo */
|
||||
|
|
@ -242,7 +242,7 @@ class WikiFilePage extends WikiPage {
|
|||
->where( [ 'page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), ] )
|
||||
->caller( __METHOD__ )->fetchResultSet();
|
||||
|
||||
return TitleArray::newFromResult( $res );
|
||||
return new TitleArrayFromResult( $res );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ use MediaWiki\Storage\PageUpdateStatus;
|
|||
use MediaWiki\Storage\PreparedUpdate;
|
||||
use MediaWiki\Storage\RevisionSlotsUpdate;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\Title\TitleArray;
|
||||
use MediaWiki\Title\TitleArrayFromResult;
|
||||
use MediaWiki\User\ActorMigration;
|
||||
use MediaWiki\User\User;
|
||||
use MediaWiki\User\UserArrayFromResult;
|
||||
|
|
@ -2883,12 +2883,12 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
* Returns a list of categories this page is a member of.
|
||||
* Results will include hidden categories
|
||||
*
|
||||
* @return TitleArray
|
||||
* @return TitleArrayFromResult
|
||||
*/
|
||||
public function getCategories() {
|
||||
$id = $this->getId();
|
||||
if ( $id == 0 ) {
|
||||
return TitleArray::newFromResult( new FakeResultWrapper( [] ) );
|
||||
return new TitleArrayFromResult( new FakeResultWrapper( [] ) );
|
||||
}
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
|
|
@ -2898,7 +2898,7 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
->where( [ 'cl_from' => $id ] )
|
||||
->caller( __METHOD__ )->fetchResultSet();
|
||||
|
||||
return TitleArray::newFromResult( $res );
|
||||
return new TitleArrayFromResult( $res );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use MediaWiki\HookContainer\HookRunner;
|
|||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Title\MediaWikiTitleCodec;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\Title\TitleArray;
|
||||
use MediaWiki\Title\TitleArrayFromResult;
|
||||
|
||||
/**
|
||||
* Handles searching prefixes of titles and finding any page
|
||||
|
|
@ -290,6 +290,6 @@ abstract class PrefixSearch {
|
|||
->offset( $offset );
|
||||
$res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
|
||||
|
||||
return iterator_to_array( TitleArray::newFromResult( $res ) );
|
||||
return iterator_to_array( new TitleArrayFromResult( $res ) );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ use MediaWiki\Permissions\RestrictionStore;
|
|||
use MediaWiki\SpecialPage\UnlistedSpecialPage;
|
||||
use MediaWiki\Title\NamespaceInfo;
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\Title\TitleArray;
|
||||
use MediaWiki\Title\TitleArrayFromResult;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use MediaWiki\Watchlist\WatchlistManager;
|
||||
use MediaWiki\Widget\ComplexTitleInputWidget;
|
||||
|
|
@ -867,7 +867,7 @@ class SpecialMovePage extends UnlistedSpecialPage {
|
|||
|
||||
$extraPages = [];
|
||||
if ( $conds !== null ) {
|
||||
$extraPages = TitleArray::newFromResult(
|
||||
$extraPages = new TitleArrayFromResult(
|
||||
$dbr->newSelectQueryBuilder()
|
||||
->select( [ 'page_id', 'page_namespace', 'page_title' ] )
|
||||
->from( 'page' )
|
||||
|
|
@ -974,11 +974,11 @@ class SpecialMovePage extends UnlistedSpecialPage {
|
|||
private function showSubpages( $title ) {
|
||||
$nsHasSubpages = $this->nsInfo->hasSubpages( $title->getNamespace() );
|
||||
$subpages = $title->getSubpages();
|
||||
$count = $subpages instanceof TitleArray ? $subpages->count() : 0;
|
||||
$count = $subpages instanceof TitleArrayFromResult ? $subpages->count() : 0;
|
||||
|
||||
$titleIsTalk = $title->isTalkPage();
|
||||
$subpagesTalk = $title->getTalkPage()->getSubpages();
|
||||
$countTalk = $subpagesTalk instanceof TitleArray ? $subpagesTalk->count() : 0;
|
||||
$countTalk = $subpagesTalk instanceof TitleArrayFromResult ? $subpagesTalk->count() : 0;
|
||||
$totalCount = $count + $countTalk;
|
||||
|
||||
if ( !$nsHasSubpages && $countTalk == 0 ) {
|
||||
|
|
|
|||
|
|
@ -2475,7 +2475,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
# if needed and don't declare it statically.
|
||||
if ( $this->mHasSubpages === null ) {
|
||||
$subpages = $this->getSubpages( 1 );
|
||||
$this->mHasSubpages = $subpages instanceof TitleArray && $subpages->count();
|
||||
$this->mHasSubpages = $subpages instanceof TitleArrayFromResult && $subpages->count();
|
||||
}
|
||||
|
||||
return $this->mHasSubpages;
|
||||
|
|
@ -2485,7 +2485,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
* Get all subpages of this page.
|
||||
*
|
||||
* @param int $limit Maximum number of subpages to fetch; -1 for no limit
|
||||
* @return TitleArray|array TitleArray, or empty array if this page's namespace
|
||||
* @return TitleArrayFromResult|array TitleArrayFromResult, or empty array if this page's namespace
|
||||
* doesn't allow subpages
|
||||
*/
|
||||
public function getSubpages( $limit = -1 ) {
|
||||
|
|
@ -2508,7 +2508,7 @@ class Title implements LinkTarget, PageIdentity, IDBAccessObject {
|
|||
->options( $options )
|
||||
->caller( __METHOD__ );
|
||||
|
||||
return TitleArray::newFromResult( $query->fetchResultSet() );
|
||||
return new TitleArrayFromResult( $query->fetchResultSet() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,16 +35,20 @@ use Wikimedia\Rdbms\IResultWrapper;
|
|||
* The documentation of the return types for the abstract current/key functions
|
||||
* helps static code analyzer to treat this as Iterator<Title>
|
||||
*
|
||||
* @deprecated since 1.41, Use TitleArrayFromResult instead.
|
||||
*
|
||||
* @method int count()
|
||||
*/
|
||||
abstract class TitleArray implements Iterator {
|
||||
/**
|
||||
* @deprecated since 1.41, Use TitleArrayFromResult instead.
|
||||
* @param IResultWrapper $res A SQL result including at least page_namespace and
|
||||
* page_title -- also can have page_id, page_len, page_is_redirect,
|
||||
* page_latest (if those will be used). See Title::newFromRow.
|
||||
* @return TitleArrayFromResult
|
||||
*/
|
||||
public static function newFromResult( $res ) {
|
||||
wfDeprecated( __METHOD__, '1.41' );
|
||||
// TODO consider merging this class with TitleArrayFromResult now that the
|
||||
// TitleArrayFromResult hook has been removed
|
||||
return new TitleArrayFromResult( $res );
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\Title\TitleArray;
|
||||
use MediaWiki\Title\TitleArrayFromResult;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +82,7 @@ class PagePropsTest extends MediaWikiLangTestCase {
|
|||
$this->createRowFromTitle( $this->title2 )
|
||||
];
|
||||
$resultWrapper = new FakeResultWrapper( $rows );
|
||||
$titles = TitleArray::newFromResult( $resultWrapper );
|
||||
$titles = new TitleArrayFromResult( $resultWrapper );
|
||||
$result = $pageProps->getProperties( $titles, "property1" );
|
||||
$this->assertArrayHasKey( $page1ID, $result, "Found page 1 property" );
|
||||
$this->assertArrayHasKey( $page2ID, $result, "Found page 2 property" );
|
||||
|
|
|
|||
Loading…
Reference in a new issue