specials: Migrate off some calls to method ChangeTags::modifyDisplayQuery

Deprecated.

Bug: T245964
Change-Id: I8ff03634564024560b354b5a770353866b9258da
This commit is contained in:
Amir Sarabadani 2023-06-16 01:17:05 +02:00
parent a5e2fff44e
commit c4afff4941
7 changed files with 40 additions and 14 deletions

View file

@ -629,6 +629,7 @@ class SpecialPageFactory {
'WatchedItemStore',
'WatchlistManager',
'UserOptionsLookup',
'ChangeTagsStore',
]
],
'Newpages' => [
@ -642,6 +643,7 @@ class SpecialPageFactory {
'NamespaceInfo',
'UserOptionsLookup',
'CommentFormatter',
'ChangeTagsStore',
]
],
'Recentchanges' => [
@ -650,6 +652,7 @@ class SpecialPageFactory {
'WatchedItemStore',
'MessageCache',
'UserOptionsLookup',
'ChangeTagsStore',
]
],
'Recentchangeslinked' => [
@ -659,6 +662,7 @@ class SpecialPageFactory {
'MessageCache',
'UserOptionsLookup',
'SearchEngineFactory',
'ChangeTagsStore',
]
],
'Tags' => [

View file

@ -22,6 +22,7 @@
*/
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\ChangeTags\ChangeTagsStore;
use MediaWiki\CommentFormatter\CommentFormatter;
use MediaWiki\CommentStore\CommentStore;
use MediaWiki\Content\IContentHandlerFactory;
@ -77,6 +78,7 @@ class SpecialNewpages extends IncludableSpecialPage {
/** @var CommentFormatter */
private $commentFormatter;
private ChangeTagsStore $changeTagsStore;
/**
* @param LinkBatchFactory $linkBatchFactory
@ -96,7 +98,8 @@ class SpecialNewpages extends IncludableSpecialPage {
RevisionLookup $revisionLookup,
NamespaceInfo $namespaceInfo,
UserOptionsLookup $userOptionsLookup,
CommentFormatter $commentFormatter
CommentFormatter $commentFormatter,
ChangeTagsStore $changeTagsStore
) {
parent::__construct( 'Newpages' );
$this->linkBatchFactory = $linkBatchFactory;
@ -107,6 +110,7 @@ class SpecialNewpages extends IncludableSpecialPage {
$this->namespaceInfo = $namespaceInfo;
$this->userOptionsLookup = $userOptionsLookup;
$this->commentFormatter = $commentFormatter;
$this->changeTagsStore = $changeTagsStore;
}
/**
@ -532,7 +536,8 @@ class SpecialNewpages extends IncludableSpecialPage {
$this->getHookContainer(),
$this->linkBatchFactory,
$this->namespaceInfo,
$this->opts
$this->opts,
$this->changeTagsStore
);
}

View file

@ -21,6 +21,7 @@
* @ingroup SpecialPage
*/
use MediaWiki\ChangeTags\ChangeTagsStore;
use MediaWiki\Html\FormOptions;
use MediaWiki\Html\Html;
use MediaWiki\MainConfigNames;
@ -50,6 +51,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
/** @var int */
public $denseRcSizeThreshold = 10000;
private ChangeTagsStore $changeTagsStore;
/**
* @param WatchedItemStoreInterface|null $watchedItemStore
@ -59,7 +61,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
public function __construct(
WatchedItemStoreInterface $watchedItemStore = null,
MessageCache $messageCache = null,
UserOptionsLookup $userOptionsLookup = null
UserOptionsLookup $userOptionsLookup = null,
ChangeTagsStore $changeTagsStore = null
) {
parent::__construct( 'Recentchanges', '' );
// This class is extended and therefor fallback to global state - T265310
@ -67,6 +70,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
$this->watchedItemStore = $watchedItemStore ?? $services->getWatchedItemStore();
$this->messageCache = $messageCache ?? $services->getMessageCache();
$this->userOptionsLookup = $userOptionsLookup ?? $services->getUserOptionsLookup();
$this->changeTagsStore = $changeTagsStore ?? $services->getChangeTagsStore();
$this->watchlistFilterGroupDefinition = [
'name' => 'watchlist',
@ -363,7 +367,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
$join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
$tagFilter = $opts['tagfilter'] !== '' ? explode( '|', $opts['tagfilter'] ) : [];
ChangeTags::modifyDisplayQuery(
$this->changeTagsStore->modifyDisplayQuery(
$tables,
$fields,
$conds,
@ -398,7 +402,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
}
if ( in_array( 'DISTINCT', $query_options ) ) {
// ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
// ChangeTagsStore::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
// In order to prevent DISTINCT from causing query performance problems,
// we have to GROUP BY the primary key. This in turn requires us to add
// the primary key to the end of the ORDER BY, and the old ORDER BY to the

View file

@ -21,6 +21,7 @@
* @ingroup SpecialPage
*/
use MediaWiki\ChangeTags\ChangeTagsStore;
use MediaWiki\Html\FormOptions;
use MediaWiki\Html\Html;
use MediaWiki\MainConfigNames;
@ -40,6 +41,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
/** @var SearchEngineFactory */
private $searchEngineFactory;
private ChangeTagsStore $changeTagsStore;
/**
* @param WatchedItemStoreInterface $watchedItemStore
@ -51,7 +53,8 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
WatchedItemStoreInterface $watchedItemStore,
MessageCache $messageCache,
UserOptionsLookup $userOptionsLookup,
SearchEngineFactory $searchEngineFactory
SearchEngineFactory $searchEngineFactory,
ChangeTagsStore $changeTagsStore
) {
parent::__construct(
$watchedItemStore,
@ -60,6 +63,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
);
$this->mName = 'Recentchangeslinked';
$this->searchEngineFactory = $searchEngineFactory;
$this->changeTagsStore = $changeTagsStore;
}
public function getDefaultOptions() {
@ -127,7 +131,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
$select[] = 'page_latest';
$tagFilter = $opts['tagfilter'] !== '' ? explode( '|', $opts['tagfilter'] ) : [];
ChangeTags::modifyDisplayQuery(
$this->changeTagsStore->modifyDisplayQuery(
$tables,
$select,
$conds,
@ -139,7 +143,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
if ( $dbr->unionSupportsOrderAndLimit() ) {
if ( in_array( 'DISTINCT', $query_options ) ) {
// ChangeTags::modifyDisplayQuery() will have added DISTINCT.
// ChangeTagsStore::modifyDisplayQuery() will have added DISTINCT.
// To prevent this from causing query performance problems, we need to add
// a GROUP BY, and add rc_id to the ORDER BY.
$order = [

View file

@ -21,6 +21,7 @@
* @ingroup SpecialPage
*/
use MediaWiki\ChangeTags\ChangeTagsStore;
use MediaWiki\Html\FormOptions;
use MediaWiki\Html\Html;
use MediaWiki\MainConfigNames;
@ -62,6 +63,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
* constants (e.g. EDIT_NORMAL)
*/
private $currentMode;
private ChangeTagsStore $changeTagsStore;
/**
* @param WatchedItemStoreInterface $watchedItemStore
@ -71,13 +73,15 @@ class SpecialWatchlist extends ChangesListSpecialPage {
public function __construct(
WatchedItemStoreInterface $watchedItemStore,
WatchlistManager $watchlistManager,
UserOptionsLookup $userOptionsLookup
UserOptionsLookup $userOptionsLookup,
ChangeTagsStore $changeTagsStore
) {
parent::__construct( 'Watchlist', 'viewmywatchlist' );
$this->watchedItemStore = $watchedItemStore;
$this->watchlistManager = $watchlistManager;
$this->userOptionsLookup = $userOptionsLookup;
$this->changeTagsStore = $changeTagsStore;
}
public function doesWrites() {
@ -436,7 +440,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
}
$tagFilter = $opts['tagfilter'] !== '' ? explode( '|', $opts['tagfilter'] ) : [];
ChangeTags::modifyDisplayQuery(
$this->changeTagsStore->modifyDisplayQuery(
$tables,
$fields,
$conds,
@ -457,7 +461,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
'LIMIT' => $opts['limit']
];
if ( in_array( 'DISTINCT', $query_options ) ) {
// ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
// ChangeTagsStore::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
// In order to prevent DISTINCT from causing query performance problems,
// we have to GROUP BY the primary key. This in turn requires us to add
// the primary key to the end of the ORDER BY, and the old ORDER BY to the

View file

@ -20,6 +20,7 @@
*/
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\ChangeTags\ChangeTagsStore;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\HookRunner;
use MediaWiki\Html\FormOptions;
@ -53,6 +54,7 @@ class NewPagesPager extends ReverseChronologicalPager {
/** @var NamespaceInfo */
private $namespaceInfo;
private ChangeTagsStore $changeTagsStore;
/**
* @param SpecialNewpages $form
@ -68,7 +70,8 @@ class NewPagesPager extends ReverseChronologicalPager {
HookContainer $hookContainer,
LinkBatchFactory $linkBatchFactory,
NamespaceInfo $namespaceInfo,
FormOptions $opts
FormOptions $opts,
ChangeTagsStore $changeTagsStore
) {
parent::__construct( $form->getContext() );
$this->groupPermissionsLookup = $groupPermissionsLookup;
@ -77,6 +80,7 @@ class NewPagesPager extends ReverseChronologicalPager {
$this->namespaceInfo = $namespaceInfo;
$this->mForm = $form;
$this->opts = $opts;
$this->changeTagsStore = $changeTagsStore;
}
public function getQueryInfo() {
@ -139,7 +143,7 @@ class NewPagesPager extends ReverseChronologicalPager {
];
// Modify query for tags
ChangeTags::modifyDisplayQuery(
$this->changeTagsStore->modifyDisplayQuery(
$info['tables'],
$info['fields'],
$info['conds'],

View file

@ -50,7 +50,8 @@ class SpecialWatchlistTest extends SpecialPageTestBase {
return new SpecialWatchlist(
$services->getWatchedItemStore(),
$services->getWatchlistManager(),
$services->getUserOptionsLookup()
$services->getUserOptionsLookup(),
$services->getChangeTagsStore()
);
}