11use MediaWiki\Cache\LinkBatchFactory;
14use MediaWiki\Languages\LanguageConverterFactory;
30 private $currentCategoryCounts;
37 LinkBatchFactory $linkBatchFactory,
38 LanguageConverterFactory $languageConverterFactory,
41 parent::__construct(
'Wantedcategories' );
44 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->
getContentLanguage() );
45 $this->linksMigration = $linksMigration;
50 $queryInfo = $this->linksMigration->getQueryInfo(
'categorylinks' );
51 $titleField = $this->linksMigration->getTitleFields(
'categorylinks' )[1];
54 'tables' => array_merge( $queryInfo[
'tables'], [
'page' ] ),
57 'title' => $titleField,
60 'conds' => [
'page_title' => null ],
61 'options' => [
'GROUP BY' => $titleField ],
62 'join_conds' => array_merge( $queryInfo[
'joins'],
63 [
'page' => [
'LEFT JOIN',
64 [
'page_title = ' . $titleField,
72 CategoryLinksTable::VIRTUAL_DOMAIN,
79 parent::preprocessResults( $db, $res );
81 $this->currentCategoryCounts = [];
83 if ( !$res->numRows() || !$this->isCached() ) {
91 foreach ( $res as $row ) {
92 $allCategories[] = $row->title;
95 $categoryRes = $db->newSelectQueryBuilder()
96 ->select( [
'cat_title',
'cat_pages' ] )
98 ->where( [
'cat_title' => $allCategories ] )
99 ->caller( __METHOD__ )->fetchResultSet();
100 foreach ( $categoryRes as $row ) {
101 $this->currentCategoryCounts[$row->cat_title] = intval( $row->cat_pages );
116 $text =
new HtmlArmor( $this->languageConverter->convertHtml( $nt->getText() ) );
124 $nlinks = $this->
msg(
'nmembers' )->numParams( $result->value )->escaped();
128 $currentValue = $this->currentCategoryCounts[$result->title] ?? 0;
129 $cachedValue = intval( $result->value );
132 if ( $nt->isKnown() || $currentValue === 0 ) {
133 $plink =
"<del>$plink</del>";
137 if ( $currentValue !== $cachedValue ) {
138 $nlinks = $this->
msg(
'nmemberschanged' )
139 ->numParams( $cachedValue, $currentValue )->escaped();
141 $nlinks = $this->
msg(
'nmembers' )->numParams( $cachedValue )->escaped();
145 return $this->
getLanguage()->specialList( $plink, $nlinks );
150 return 'maintenance';
158class_alias( SpecialWantedCategories::class,
'SpecialWantedCategories' );
setDatabaseProvider(IConnectionProvider $databaseProvider)
isCached()
Whether or not the output of the page in question is retrieved from the database cache.
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
Base class for a "wanted" query page like WantedPages, WantedTemplates, etc.