Use LinkBatchFactory in pagers, special pages and actions
Change-Id: I299900316c8d3129844a047228cd1c15ae7dff63
This commit is contained in:
parent
0ddef21c9b
commit
42507e73cd
40 changed files with 324 additions and 100 deletions
|
|
@ -299,7 +299,15 @@ class HistoryAction extends FormlessAction {
|
|||
$m = '';
|
||||
$d = '';
|
||||
}
|
||||
$pager = new HistoryPager( $this, $y, $m, $tagFilter, $conds, $d );
|
||||
$pager = new HistoryPager(
|
||||
$this,
|
||||
$y,
|
||||
$m,
|
||||
$tagFilter,
|
||||
$conds,
|
||||
$d,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
$out->addHTML(
|
||||
$pager->getNavigationBar() .
|
||||
$pager->getBody() .
|
||||
|
|
|
|||
|
|
@ -541,8 +541,8 @@ class InfoAction extends FormlessAction {
|
|||
->getRevisionLookup()
|
||||
->getFirstRevision( $this->getTitle() );
|
||||
$lastRev = $this->getWikiPage()->getRevisionRecord();
|
||||
$batch = new LinkBatch;
|
||||
|
||||
$linkBatchFactory = $services->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
if ( $firstRev ) {
|
||||
$firstRevUser = $firstRev->getUser( RevisionRecord::FOR_THIS_USER, $user );
|
||||
if ( $firstRevUser ) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* @ingroup Actions
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use MediaWiki\Revision\RevisionStore;
|
||||
|
|
@ -54,6 +55,9 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
/** @var RevisionStore */
|
||||
private $revisionStore;
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param HistoryAction $historyPage
|
||||
* @param string $year
|
||||
|
|
@ -61,6 +65,7 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
* @param string $tagFilter
|
||||
* @param array $conds
|
||||
* @param string $day
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct(
|
||||
HistoryAction $historyPage,
|
||||
|
|
@ -68,7 +73,8 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
$month = '',
|
||||
$tagFilter = '',
|
||||
array $conds = [],
|
||||
$day = ''
|
||||
$day = '',
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
parent::__construct( $historyPage->getContext() );
|
||||
$this->historyPage = $historyPage;
|
||||
|
|
@ -77,6 +83,7 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
$this->conds = $conds;
|
||||
$this->showTagEditUI = ChangeTags::showTagEditingUI( $this->getUser() );
|
||||
$this->revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
// For hook compatibility...
|
||||
|
|
@ -150,7 +157,7 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
|
||||
# Do a link batch query
|
||||
$this->mResult->seek( 0 );
|
||||
$batch = new LinkBatch();
|
||||
$batch = $this->linkBatchFactory->newLinkBatch();
|
||||
$revIds = [];
|
||||
foreach ( $this->mResult as $row ) {
|
||||
if ( $row->rev_parent_id ) {
|
||||
|
|
|
|||
|
|
@ -90,18 +90,22 @@ class ApiFeedContributions extends ApiBase {
|
|||
$params['end'] = '';
|
||||
$params = ContribsPager::processDateFilter( $params );
|
||||
|
||||
$pager = new ContribsPager( $this->getContext(), [
|
||||
'target' => $target,
|
||||
'namespace' => $params['namespace'],
|
||||
'start' => $params['start'],
|
||||
'end' => $params['end'],
|
||||
'tagFilter' => $params['tagfilter'],
|
||||
'deletedOnly' => $params['deletedonly'],
|
||||
'topOnly' => $params['toponly'],
|
||||
'newOnly' => $params['newonly'],
|
||||
'hideMinor' => $params['hideminor'],
|
||||
'showSizeDiff' => $params['showsizediff'],
|
||||
] );
|
||||
$pager = new ContribsPager(
|
||||
$this->getContext(), [
|
||||
'target' => $target,
|
||||
'namespace' => $params['namespace'],
|
||||
'start' => $params['start'],
|
||||
'end' => $params['end'],
|
||||
'tagFilter' => $params['tagfilter'],
|
||||
'deletedOnly' => $params['deletedonly'],
|
||||
'topOnly' => $params['toponly'],
|
||||
'newOnly' => $params['newonly'],
|
||||
'hideMinor' => $params['hideminor'],
|
||||
'showSizeDiff' => $params['showsizediff'],
|
||||
],
|
||||
MediaWikiServices::getInstance()->getLinkRenderer(),
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
|
||||
$feedLimit = $this->getConfig()->get( 'FeedLimit' );
|
||||
if ( $pager->getLimit() > $feedLimit ) {
|
||||
|
|
|
|||
|
|
@ -679,7 +679,21 @@ class LogEventsList extends ContextSource {
|
|||
|
||||
# Insert list of top 50 (or top $lim) items
|
||||
$loglist = new LogEventsList( $context, $linkRenderer, $flags );
|
||||
$pager = new LogPager( $loglist, $types, $user, $page, '', $conds );
|
||||
$pager = new LogPager(
|
||||
$loglist,
|
||||
$types,
|
||||
$user,
|
||||
$page,
|
||||
'',
|
||||
$conds,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
if ( !$useRequestParams ) {
|
||||
# Reset vars that may have been taken from the request
|
||||
$pager->mLimit = 50;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
|
|
@ -62,6 +63,9 @@ class LogPager extends ReverseChronologicalPager {
|
|||
/** @var LogEventsList */
|
||||
public $mLogEventsList;
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param LogEventsList $list
|
||||
* @param string|array $types Log types to show
|
||||
|
|
@ -75,10 +79,12 @@ class LogPager extends ReverseChronologicalPager {
|
|||
* @param string $tagFilter Tag
|
||||
* @param string $action Specific action (subtype) requested
|
||||
* @param int $logId Log entry ID, to limit to a single log entry.
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( $list, $types = [], $performer = '', $title = '',
|
||||
$pattern = false, $conds = [], $year = false, $month = false, $day = false,
|
||||
$tagFilter = '', $action = '', $logId = 0
|
||||
$tagFilter = '', $action = '', $logId = 0,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
parent::__construct( $list->getContext() );
|
||||
$this->mConds = $conds;
|
||||
|
|
@ -93,6 +99,7 @@ class LogPager extends ReverseChronologicalPager {
|
|||
$this->limitAction( $action );
|
||||
$this->getDateCond( $year, $month, $day );
|
||||
$this->mTagFilter = $tagFilter;
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
|
||||
$this->mDb = wfGetDB( DB_REPLICA, 'logpager' );
|
||||
}
|
||||
|
|
@ -397,7 +404,7 @@ class LogPager extends ReverseChronologicalPager {
|
|||
protected function getStartBody() {
|
||||
# Do a link batch query
|
||||
if ( $this->getNumRows() > 0 ) {
|
||||
$lb = new LinkBatch;
|
||||
$lb = $this->linkBatchFactory->newLinkBatch();
|
||||
foreach ( $this->mResult as $row ) {
|
||||
$lb->add( $row->log_namespace, $row->log_title );
|
||||
$lb->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Timestamp\TimestampException;
|
||||
|
||||
class ImageHistoryPseudoPager extends ReverseChronologicalPager {
|
||||
|
|
@ -51,10 +53,14 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
|
|||
*/
|
||||
public $mRange;
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param ImagePage $imagePage
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( $imagePage ) {
|
||||
public function __construct( $imagePage, LinkBatchFactory $linkBatchFactory = null ) {
|
||||
parent::__construct( $imagePage->getContext() );
|
||||
$this->mImagePage = $imagePage;
|
||||
$this->mTitle = $imagePage->getTitle()->createFragmentTarget( 'filehistory' );
|
||||
|
|
@ -71,6 +77,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
|
|||
$this->mDefaultLimit,
|
||||
''
|
||||
);
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -108,7 +115,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
|
|||
if ( count( $this->mHist ) ) {
|
||||
if ( $this->mImg->isLocal() ) {
|
||||
// Do a batch existence check for user pages and talkpages
|
||||
$linkBatch = new LinkBatch();
|
||||
$linkBatch = $this->linkBatchFactory->newLinkBatch();
|
||||
for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
|
||||
$file = $this->mHist[$i];
|
||||
$user = $file->getUser( 'text' );
|
||||
|
|
|
|||
|
|
@ -807,7 +807,10 @@ EOT
|
|||
protected function imageHistory() {
|
||||
$this->loadFile();
|
||||
$out = $this->getContext()->getOutput();
|
||||
$pager = new ImageHistoryPseudoPager( $this );
|
||||
$pager = new ImageHistoryPseudoPager(
|
||||
$this,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
$out->addHTML( $pager->getBody() );
|
||||
$out->preventClickjacking( $pager->getPreventClickjacking() );
|
||||
|
||||
|
|
|
|||
|
|
@ -657,7 +657,8 @@ abstract class ChangesListSpecialPage extends SpecialPage {
|
|||
return;
|
||||
}
|
||||
|
||||
$batch = new LinkBatch;
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $rows as $row ) {
|
||||
$batch->add( NS_USER, $row->rc_user_text );
|
||||
$batch->add( NS_USER_TALK, $row->rc_user_text );
|
||||
|
|
|
|||
|
|
@ -825,7 +825,8 @@ abstract class QueryPage extends SpecialPage {
|
|||
return;
|
||||
}
|
||||
|
||||
$batch = new LinkBatch;
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $res as $row ) {
|
||||
$batch->add( $ns ?? $row->namespace, $row->title );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* Implements Special:Activeusers
|
||||
*
|
||||
|
|
@ -56,7 +58,11 @@ class SpecialActiveUsers extends SpecialPage {
|
|||
$opts->setValue( 'username', $par );
|
||||
}
|
||||
|
||||
$pager = new ActiveUsersPager( $this->getContext(), $opts );
|
||||
$pager = new ActiveUsersPager(
|
||||
$this->getContext(),
|
||||
$opts,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
$usersBody = $pager->getBody();
|
||||
|
||||
$this->buildForm();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Permissions\PermissionManager;
|
||||
|
||||
/**
|
||||
|
|
@ -95,7 +96,11 @@ class SpecialAutoblockList extends SpecialPage {
|
|||
$conds['ipb_deleted'] = 0;
|
||||
}
|
||||
|
||||
return new BlockListPager( $this, $conds );
|
||||
return new BlockListPager(
|
||||
$this,
|
||||
$conds,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -202,7 +202,11 @@ class SpecialBlockList extends SpecialPage {
|
|||
$conds['ipb_sitewide'] = 0;
|
||||
}
|
||||
|
||||
return new BlockListPager( $this, $conds );
|
||||
return new BlockListPager(
|
||||
$this,
|
||||
$conds,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
|
@ -45,7 +47,8 @@ class SpecialCategories extends SpecialPage {
|
|||
$cap = new CategoryPager(
|
||||
$this->getContext(),
|
||||
$from,
|
||||
$this->getLinkRenderer()
|
||||
$this->getLinkRenderer(),
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
$cap->doQuery();
|
||||
|
||||
|
|
|
|||
|
|
@ -217,19 +217,23 @@ class SpecialContributions extends IncludableSpecialPage {
|
|||
if ( $this->getHookRunner()->onSpecialContributionsBeforeMainOutput(
|
||||
$id, $userObj, $this )
|
||||
) {
|
||||
$pager = new ContribsPager( $this->getContext(), [
|
||||
'target' => $target,
|
||||
'namespace' => $this->opts['namespace'],
|
||||
'tagfilter' => $this->opts['tagfilter'],
|
||||
'start' => $this->opts['start'],
|
||||
'end' => $this->opts['end'],
|
||||
'deletedOnly' => $this->opts['deletedOnly'],
|
||||
'topOnly' => $this->opts['topOnly'],
|
||||
'newOnly' => $this->opts['newOnly'],
|
||||
'hideMinor' => $this->opts['hideMinor'],
|
||||
'nsInvert' => $this->opts['nsInvert'],
|
||||
'associated' => $this->opts['associated'],
|
||||
], $this->getLinkRenderer() );
|
||||
$pager = new ContribsPager(
|
||||
$this->getContext(), [
|
||||
'target' => $target,
|
||||
'namespace' => $this->opts['namespace'],
|
||||
'tagfilter' => $this->opts['tagfilter'],
|
||||
'start' => $this->opts['start'],
|
||||
'end' => $this->opts['end'],
|
||||
'deletedOnly' => $this->opts['deletedOnly'],
|
||||
'topOnly' => $this->opts['topOnly'],
|
||||
'newOnly' => $this->opts['newOnly'],
|
||||
'hideMinor' => $this->opts['hideMinor'],
|
||||
'nsInvert' => $this->opts['nsInvert'],
|
||||
'associated' => $this->opts['associated'],
|
||||
],
|
||||
$this->getLinkRenderer(),
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
if ( !$this->including() ) {
|
||||
$out->addHTML( $this->getForm( $this->opts ) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,7 +219,8 @@ class SpecialDoubleRedirects extends QueryPage {
|
|||
return;
|
||||
}
|
||||
|
||||
$batch = new LinkBatch;
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $res as $row ) {
|
||||
$batch->add( $row->namespace, $row->title );
|
||||
if ( isset( $row->b_namespace ) ) {
|
||||
|
|
|
|||
|
|
@ -329,7 +329,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
|
|||
private function showTitles( $titles, &$output ) {
|
||||
$talk = $this->msg( 'talkpagelinktext' )->text();
|
||||
// Do a batch existence check
|
||||
$batch = new LinkBatch();
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
if ( count( $titles ) >= 100 ) {
|
||||
$output = $this->msg( 'watchlistedit-too-many' )->parse();
|
||||
return;
|
||||
|
|
@ -429,7 +430,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
|
|||
$this->getUser(), $options
|
||||
);
|
||||
|
||||
$lb = new LinkBatch();
|
||||
$linkBatchFactory = $services->getLinkBatchFactory();
|
||||
$lb = $linkBatchFactory->newLinkBatch();
|
||||
$context = $this->getContext();
|
||||
|
||||
foreach ( $watchedItems as $watchedItem ) {
|
||||
|
|
|
|||
|
|
@ -186,7 +186,8 @@ class SpecialFileDuplicateSearch extends QueryPage {
|
|||
}
|
||||
|
||||
private function doBatchLookups( $list ) {
|
||||
$batch = new LinkBatch();
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
/** @var File $file */
|
||||
foreach ( $list as $file ) {
|
||||
$batch->addObj( $file->getTitle() );
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
* @author Rob Church <robchur@gmail.com>
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
|
||||
|
|
@ -82,7 +83,8 @@ class SpecialListRedirects extends QueryPage {
|
|||
return;
|
||||
}
|
||||
|
||||
$batch = new LinkBatch;
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $res as $row ) {
|
||||
$batch->add( $row->namespace, $row->title );
|
||||
$redirTarget = $this->getRedirectTarget( $row );
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
|
@ -41,7 +43,12 @@ class SpecialListUsers extends IncludableSpecialPage {
|
|||
$this->setHeaders();
|
||||
$this->outputHeader();
|
||||
|
||||
$up = new UsersPager( $this->getContext(), $par, $this->including() );
|
||||
$up = new UsersPager(
|
||||
$this->getContext(),
|
||||
$par,
|
||||
$this->including(),
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
|
||||
# getBody() first to check, if empty
|
||||
$usersbody = $up->getBody();
|
||||
|
|
|
|||
|
|
@ -213,7 +213,8 @@ class SpecialLog extends SpecialPage {
|
|||
$opts->getValue( 'day' ),
|
||||
$opts->getValue( 'tagfilter' ),
|
||||
$opts->getValue( 'subtype' ),
|
||||
$opts->getValue( 'logid' )
|
||||
$opts->getValue( 'logid' ),
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
|
||||
$this->addHeader( $opts->getValue( 'type' ) );
|
||||
|
|
|
|||
|
|
@ -195,7 +195,11 @@ class SpecialMergeHistory extends SpecialPage {
|
|||
|
||||
# List all stored revisions
|
||||
$revisions = new MergeHistoryPager(
|
||||
$this, [], $this->mTargetObj, $this->mDestObj
|
||||
$this,
|
||||
[],
|
||||
$this->mTargetObj,
|
||||
$this->mDestObj,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
$haveRevisions = $revisions->getNumRows() > 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -892,7 +892,8 @@ class MovePageForm extends UnlistedSpecialPage {
|
|||
$out->addWikiMsg( $wikiMsg, $this->getLanguage()->formatNum( $pagecount ) );
|
||||
$out->addHTML( "<ul>\n" );
|
||||
|
||||
$linkBatch = new LinkBatch( $subpages );
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$linkBatch = $linkBatchFactory->newLinkBatch( $subpages );
|
||||
$linkBatch->setCaller( __METHOD__ );
|
||||
$linkBatch->execute();
|
||||
$linkRenderer = $this->getLinkRenderer();
|
||||
|
|
|
|||
|
|
@ -159,7 +159,11 @@ class SpecialNewpages extends IncludableSpecialPage {
|
|||
$out->setFeedAppendQuery( wfArrayToCgi( $allValues ) );
|
||||
}
|
||||
|
||||
$pager = new NewPagesPager( $this, $this->opts );
|
||||
$pager = new NewPagesPager(
|
||||
$this,
|
||||
$this->opts,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
$pager->mLimit = $this->opts->getValue( 'limit' );
|
||||
$pager->mOffset = $this->opts->getValue( 'offset' );
|
||||
|
||||
|
|
@ -498,7 +502,11 @@ class SpecialNewpages extends IncludableSpecialPage {
|
|||
$this->getPageTitle()->getFullURL()
|
||||
);
|
||||
|
||||
$pager = new NewPagesPager( $this, $this->opts );
|
||||
$pager = new NewPagesPager(
|
||||
$this,
|
||||
$this->opts,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
$limit = $this->opts->getValue( 'limit' );
|
||||
$pager->mLimit = min( $limit, $this->getConfig()->get( 'FeedLimit' ) );
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* A special page that lists protected pages
|
||||
*
|
||||
|
|
@ -63,7 +65,8 @@ class SpecialProtectedpages extends SpecialPage {
|
|||
$indefOnly,
|
||||
$cascadeOnly,
|
||||
$noRedirect,
|
||||
$this->getLinkRenderer()
|
||||
$this->getLinkRenderer(),
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
|
||||
$this->getOutput()->addHTML( $this->showOptions(
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* A special page that list protected titles from creation
|
||||
*
|
||||
|
|
@ -46,7 +48,16 @@ class SpecialProtectedtitles extends SpecialPage {
|
|||
$size = $request->getIntOrNull( 'size' );
|
||||
$NS = $request->getIntOrNull( 'namespace' );
|
||||
|
||||
$pager = new ProtectedTitlesPager( $this, [], $type, $level, $NS, $sizetype, $size );
|
||||
$pager = new ProtectedTitlesPager(
|
||||
$this,
|
||||
[],
|
||||
$type,
|
||||
$level,
|
||||
$NS,
|
||||
$sizetype,
|
||||
$size,
|
||||
MediaWikiServices::getInstance()->getLinkBatchFactory()
|
||||
);
|
||||
|
||||
$this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) );
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup SpecialPage
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* A special page that displays list of tracking categories
|
||||
* Tracking categories allow pages with certain characteristics to be tracked.
|
||||
|
|
@ -62,7 +64,8 @@ class SpecialTrackingCategories extends SpecialPage {
|
|||
$trackingCategories = new TrackingCategories( $this->getConfig() );
|
||||
$categoryList = $trackingCategories->getTrackingCategories();
|
||||
|
||||
$batch = new LinkBatch();
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $categoryList as $catMsg => $data ) {
|
||||
$batch->addObj( $data['msg'] );
|
||||
foreach ( $data['cats'] as $catTitle ) {
|
||||
|
|
|
|||
|
|
@ -811,7 +811,8 @@ class SpecialUndelete extends SpecialPage {
|
|||
|
||||
# Batch existence check on user and talk pages
|
||||
if ( $haveRevisions ) {
|
||||
$batch = new LinkBatch();
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $revisions as $row ) {
|
||||
$batch->addObj( Title::makeTitleSafe( NS_USER, $row->ar_user_text ) );
|
||||
$batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->ar_user_text ) );
|
||||
|
|
@ -820,7 +821,8 @@ class SpecialUndelete extends SpecialPage {
|
|||
$revisions->seek( 0 );
|
||||
}
|
||||
if ( $haveFiles ) {
|
||||
$batch = new LinkBatch();
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $files as $row ) {
|
||||
$batch->addObj( Title::makeTitleSafe( NS_USER, $row->fa_user_text ) );
|
||||
$batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->fa_user_text ) );
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
* @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
|
||||
|
|
@ -57,7 +58,8 @@ class SpecialUnwatchedPages extends QueryPage {
|
|||
return;
|
||||
}
|
||||
|
||||
$batch = new LinkBatch();
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$batch = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $res as $row ) {
|
||||
$batch->add( $row->namespace, $row->title );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,7 +301,8 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
|
|||
|
||||
// use LinkBatch to make sure, that all required data (associated with Titles)
|
||||
// is loaded in one query
|
||||
$lb = new LinkBatch();
|
||||
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
$lb = $linkBatchFactory->newLinkBatch();
|
||||
foreach ( $rows as $row ) {
|
||||
$lb->add( $row->page_namespace, $row->page_title );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
|
|
@ -54,9 +55,14 @@ class ActiveUsersPager extends UsersPager {
|
|||
/**
|
||||
* @param IContextSource|null $context
|
||||
* @param FormOptions $opts
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( ?IContextSource $context, FormOptions $opts ) {
|
||||
parent::__construct( $context );
|
||||
public function __construct(
|
||||
?IContextSource $context,
|
||||
FormOptions $opts,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
parent::__construct( $context, null, null, $linkBatchFactory );
|
||||
|
||||
$this->RCMaxAge = $this->getConfig()->get( 'ActiveUserDays' );
|
||||
$this->requestedUser = '';
|
||||
|
|
|
|||
|
|
@ -19,18 +19,19 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup Pager
|
||||
*/
|
||||
use MediaWiki\Block\DatabaseBlock;
|
||||
use MediaWiki\Block\Restriction\NamespaceRestriction;
|
||||
use MediaWiki\Block\Restriction\PageRestriction;
|
||||
use MediaWiki\Block\Restriction\Restriction;
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\User\UserIdentity;
|
||||
use Wikimedia\IPUtils;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
|
||||
/**
|
||||
* @ingroup Pager
|
||||
*/
|
||||
class BlockListPager extends TablePager {
|
||||
|
||||
protected $conds;
|
||||
|
|
@ -42,14 +43,23 @@ class BlockListPager extends TablePager {
|
|||
*/
|
||||
protected $restrictions = [];
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param SpecialPage $page
|
||||
* @param array $conds
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( $page, $conds ) {
|
||||
public function __construct(
|
||||
$page,
|
||||
$conds,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
parent::__construct( $page->getContext(), $page->getLinkRenderer() );
|
||||
$this->conds = $conds;
|
||||
$this->mDefaultDirection = IndexPager::DIR_DESCENDING;
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
protected function getFieldNames() {
|
||||
|
|
@ -420,8 +430,9 @@ class BlockListPager extends TablePager {
|
|||
* @param IResultWrapper $result
|
||||
*/
|
||||
public function preprocessResults( $result ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
# Do a link batch query
|
||||
$lb = new LinkBatch;
|
||||
$lb = $this->linkBatchFactory->newLinkBatch();
|
||||
$lb->setCaller( __METHOD__ );
|
||||
|
||||
$partialBlocks = [];
|
||||
|
|
@ -442,7 +453,7 @@ class BlockListPager extends TablePager {
|
|||
if ( $partialBlocks ) {
|
||||
// Mutations to the $row object are not persisted. The restrictions will
|
||||
// need be stored in a separate store.
|
||||
$blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
|
||||
$blockRestrictionStore = $services->getBlockRestrictionStore();
|
||||
$this->restrictions = $blockRestrictionStore->loadByBlockId( $partialBlocks );
|
||||
|
||||
foreach ( $this->restrictions as $restriction ) {
|
||||
|
|
|
|||
|
|
@ -18,19 +18,30 @@
|
|||
* @file
|
||||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @ingroup Pager
|
||||
*/
|
||||
class CategoryPager extends AlphabeticPager {
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param IContextSource $context
|
||||
* @param string $from
|
||||
* @param LinkRenderer $linkRenderer
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( IContextSource $context, $from, LinkRenderer $linkRenderer
|
||||
public function __construct(
|
||||
IContextSource $context,
|
||||
$from,
|
||||
LinkRenderer $linkRenderer,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
parent::__construct( $context, $linkRenderer );
|
||||
$from = str_replace( ' ', '_', $from );
|
||||
|
|
@ -39,6 +50,7 @@ class CategoryPager extends AlphabeticPager {
|
|||
$this->setOffset( $from );
|
||||
$this->setIncludeOffset( true );
|
||||
}
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
public function getQueryInfo() {
|
||||
|
|
@ -62,7 +74,7 @@ class CategoryPager extends AlphabeticPager {
|
|||
|
||||
/* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
|
||||
public function getBody() {
|
||||
$batch = new LinkBatch;
|
||||
$batch = $this->linkBatchFactory->newLinkBatch();
|
||||
|
||||
$this->mResult->rewind();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,7 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pager for Special:Contributions
|
||||
* @ingroup Pager
|
||||
*/
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
|
|
@ -31,6 +28,10 @@ use Wikimedia\Rdbms\FakeResultWrapper;
|
|||
use Wikimedia\Rdbms\IDatabase;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
|
||||
/**
|
||||
* Pager for Special:Contributions
|
||||
* @ingroup Pager
|
||||
*/
|
||||
class ContribsPager extends RangeChronologicalPager {
|
||||
|
||||
/**
|
||||
|
|
@ -102,8 +103,14 @@ class ContribsPager extends RangeChronologicalPager {
|
|||
*/
|
||||
private $templateParser;
|
||||
|
||||
public function __construct( IContextSource $context, array $options,
|
||||
LinkRenderer $linkRenderer = null
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
public function __construct(
|
||||
IContextSource $context,
|
||||
array $options,
|
||||
LinkRenderer $linkRenderer = null,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
// Set ->target before calling parent::__construct() so
|
||||
// parent can call $this->getIndexField() and get the right result. Set
|
||||
|
|
@ -148,6 +155,7 @@ class ContribsPager extends RangeChronologicalPager {
|
|||
// with extra user based indexes or partioning by user.
|
||||
$this->mDb = wfGetDB( DB_REPLICA, 'contributions' );
|
||||
$this->templateParser = new TemplateParser();
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
public function getDefaultQuery() {
|
||||
|
|
@ -494,7 +502,7 @@ class ContribsPager extends RangeChronologicalPager {
|
|||
$this->mResult->seek( 0 );
|
||||
$parentRevIds = [];
|
||||
$this->mParentLens = [];
|
||||
$batch = new LinkBatch();
|
||||
$batch = $this->linkBatchFactory->newLinkBatch();
|
||||
$isIpRange = $this->isQueryableRange( $this->target );
|
||||
# Give some pointers to make (last) links
|
||||
foreach ( $this->mResult as $row ) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +39,16 @@ class MergeHistoryPager extends ReverseChronologicalPager {
|
|||
/** @var int */
|
||||
private $maxTimestamp;
|
||||
|
||||
public function __construct( SpecialMergeHistory $form, $conds, Title $source, Title $dest ) {
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
public function __construct(
|
||||
SpecialMergeHistory $form,
|
||||
$conds,
|
||||
Title $source,
|
||||
Title $dest,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
$this->mForm = $form;
|
||||
$this->mConds = $conds;
|
||||
$this->articleID = $source->getArticleID();
|
||||
|
|
@ -53,12 +63,13 @@ class MergeHistoryPager extends ReverseChronologicalPager {
|
|||
$this->maxTimestamp = $maxtimestamp;
|
||||
|
||||
parent::__construct( $form->getContext() );
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
protected function getStartBody() {
|
||||
# Do a link batch query
|
||||
$this->mResult->seek( 0 );
|
||||
$batch = new LinkBatch();
|
||||
$batch = $this->linkBatchFactory->newLinkBatch();
|
||||
# Give some pointers to make (last) links
|
||||
$this->mForm->prevId = [];
|
||||
$rev_id = null;
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @ingroup Pager
|
||||
*/
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
class NewPagesPager extends ReverseChronologicalPager {
|
||||
|
||||
/**
|
||||
|
|
@ -36,14 +37,23 @@ class NewPagesPager extends ReverseChronologicalPager {
|
|||
*/
|
||||
protected $mForm;
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param SpecialNewpages $form
|
||||
* @param FormOptions $opts
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( $form, FormOptions $opts ) {
|
||||
public function __construct(
|
||||
$form,
|
||||
FormOptions $opts,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
parent::__construct( $form->getContext() );
|
||||
$this->mForm = $form;
|
||||
$this->opts = $opts;
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
public function getQueryInfo() {
|
||||
|
|
@ -166,7 +176,7 @@ class NewPagesPager extends ReverseChronologicalPager {
|
|||
|
||||
protected function getStartBody() {
|
||||
# Do a batch existence check on pages
|
||||
$linkBatch = new LinkBatch();
|
||||
$linkBatch = $this->linkBatchFactory->newLinkBatch();
|
||||
foreach ( $this->mResult as $row ) {
|
||||
$linkBatch->add( NS_USER, $row->rc_user_text );
|
||||
$linkBatch->add( NS_USER_TALK, $row->rc_user_text );
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
|
|
@ -27,6 +28,9 @@ class ProtectedPagesPager extends TablePager {
|
|||
public $mConds;
|
||||
private $type, $level, $namespace, $sizetype, $size, $indefonly, $cascadeonly, $noredirect;
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param SpecialPage $form
|
||||
* @param array $conds
|
||||
|
|
@ -39,10 +43,21 @@ class ProtectedPagesPager extends TablePager {
|
|||
* @param bool $cascadeonly
|
||||
* @param bool $noredirect
|
||||
* @param LinkRenderer $linkRenderer
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( $form, $conds, $type, $level, $namespace,
|
||||
$sizetype, $size, $indefonly, $cascadeonly, $noredirect,
|
||||
LinkRenderer $linkRenderer
|
||||
public function __construct(
|
||||
$form,
|
||||
$conds,
|
||||
$type,
|
||||
$level,
|
||||
$namespace,
|
||||
$sizetype,
|
||||
$size,
|
||||
$indefonly,
|
||||
$cascadeonly,
|
||||
$noredirect,
|
||||
LinkRenderer $linkRenderer,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
parent::__construct( $form->getContext(), $linkRenderer );
|
||||
$this->mConds = $conds;
|
||||
|
|
@ -54,11 +69,12 @@ class ProtectedPagesPager extends TablePager {
|
|||
$this->indefonly = (bool)$indefonly;
|
||||
$this->cascadeonly = (bool)$cascadeonly;
|
||||
$this->noredirect = (bool)$noredirect;
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
public function preprocessResults( $result ) {
|
||||
# Do a link batch query
|
||||
$lb = new LinkBatch;
|
||||
$lb = $this->linkBatchFactory->newLinkBatch();
|
||||
$userids = [];
|
||||
|
||||
foreach ( $result as $row ) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @ingroup Pager
|
||||
*/
|
||||
|
|
@ -40,6 +43,9 @@ class ProtectedTitlesPager extends AlphabeticPager {
|
|||
/** @var int|null */
|
||||
private $namespace;
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param SpecialProtectedtitles $form
|
||||
* @param array $conds
|
||||
|
|
@ -48,21 +54,30 @@ class ProtectedTitlesPager extends AlphabeticPager {
|
|||
* @param int|null $namespace
|
||||
* @param string|null $sizetype
|
||||
* @param int|null $size
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( $form, $conds, $type, $level, $namespace,
|
||||
$sizetype = '', $size = 0
|
||||
public function __construct(
|
||||
$form,
|
||||
$conds,
|
||||
$type,
|
||||
$level,
|
||||
$namespace,
|
||||
$sizetype = '',
|
||||
$size = 0,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
$this->mForm = $form;
|
||||
$this->mConds = $conds;
|
||||
$this->level = $level;
|
||||
$this->namespace = $namespace;
|
||||
parent::__construct( $form->getContext() );
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
protected function getStartBody() {
|
||||
# Do a link batch query
|
||||
$this->mResult->seek( 0 );
|
||||
$lb = new LinkBatch;
|
||||
$lb = $this->linkBatchFactory->newLinkBatch();
|
||||
|
||||
foreach ( $this->mResult as $row ) {
|
||||
$lb->add( $row->pt_namespace, $row->pt_title );
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
* @ingroup Pager
|
||||
*/
|
||||
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
|
|
@ -57,13 +58,22 @@ class UsersPager extends AlphabeticPager {
|
|||
/** @var string */
|
||||
protected $requestedUser;
|
||||
|
||||
/** @var LinkBatchFactory */
|
||||
private $linkBatchFactory;
|
||||
|
||||
/**
|
||||
* @param IContextSource|null $context
|
||||
* @param array|null $par (Default null)
|
||||
* @param bool|null $including Whether this page is being transcluded in
|
||||
* another page
|
||||
* @param LinkBatchFactory|null $linkBatchFactory
|
||||
*/
|
||||
public function __construct( IContextSource $context = null, $par = null, $including = null ) {
|
||||
public function __construct(
|
||||
IContextSource $context = null,
|
||||
$par = null,
|
||||
$including = null,
|
||||
LinkBatchFactory $linkBatchFactory = null
|
||||
) {
|
||||
if ( $context ) {
|
||||
$this->setContext( $context );
|
||||
}
|
||||
|
|
@ -108,6 +118,7 @@ class UsersPager extends AlphabeticPager {
|
|||
}
|
||||
|
||||
parent::__construct();
|
||||
$this->linkBatchFactory = $linkBatchFactory ?? MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -251,7 +262,7 @@ class UsersPager extends AlphabeticPager {
|
|||
}
|
||||
|
||||
protected function doBatchLookups() {
|
||||
$batch = new LinkBatch();
|
||||
$batch = $this->linkBatchFactory->newLinkBatch();
|
||||
$userIds = [];
|
||||
# Give some pointers to make user links
|
||||
foreach ( $this->mResult as $row ) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use MediaWiki\Block\DatabaseBlock;
|
||||
use MediaWiki\Block\Restriction\NamespaceRestriction;
|
||||
use MediaWiki\Block\Restriction\PageRestriction;
|
||||
use MediaWiki\Cache\LinkBatchFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
|
||||
|
|
@ -13,14 +14,14 @@ use Wikimedia\TestingAccessWrapper;
|
|||
class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
/**
|
||||
* @var LinkRenderer
|
||||
* @var LinkBatchFactory
|
||||
*/
|
||||
private $linkRenderer;
|
||||
private $linkBatchFactory;
|
||||
|
||||
protected function setUp() : void {
|
||||
parent::setUp();
|
||||
|
||||
$this->linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
||||
$this->linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +39,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
|||
$expected = $expected ?? MWTimestamp::getInstance()->format( 'H:i, j F Y' );
|
||||
|
||||
$row = $row ?: (object)[];
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkRenderer );
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkBatchFactory );
|
||||
$wrappedPager = TestingAccessWrapper::newFromObject( $pager );
|
||||
$wrappedPager->mCurrentRow = $row;
|
||||
|
||||
|
|
@ -127,7 +128,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
|||
'wgScript' => '/w/index.php',
|
||||
] );
|
||||
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkRenderer );
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkBatchFactory );
|
||||
|
||||
$row = (object)[
|
||||
'ipb_id' => 0,
|
||||
|
|
@ -207,7 +208,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
|||
'ipb_sitewide' => 1,
|
||||
'ipb_timestamp' => $this->db->timestamp( wfTimestamp( TS_MW ) ),
|
||||
];
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkRenderer );
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkBatchFactory );
|
||||
$pager->preprocessResults( [ $row ] );
|
||||
|
||||
foreach ( $links as $link ) {
|
||||
|
|
@ -220,7 +221,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
|||
'by_user_name' => 'Admin',
|
||||
'ipb_sitewide' => 1,
|
||||
];
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkRenderer );
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkBatchFactory );
|
||||
$pager->preprocessResults( [ $row ] );
|
||||
|
||||
$this->assertObjectNotHasAttribute( 'ipb_restrictions', $row );
|
||||
|
|
@ -246,7 +247,7 @@ class BlockListPagerTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$result = $this->db->select( 'ipblocks', [ '*' ], [ 'ipb_id' => $block->getId() ] );
|
||||
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkRenderer );
|
||||
$pager = new BlockListPager( new SpecialPage(), [], $this->linkBatchFactory );
|
||||
$pager->preprocessResults( $result );
|
||||
|
||||
$wrappedPager = TestingAccessWrapper::newFromObject( $pager );
|
||||
|
|
|
|||
Loading…
Reference in a new issue