MediaWiki master
SpecialFewestRevisions.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
18use stdClass;
23
31
32 private readonly ILanguageConverter $languageConverter;
33
34 public function __construct(
35 private readonly NamespaceInfo $namespaceInfo,
36 IConnectionProvider $dbProvider,
37 LinkBatchFactory $linkBatchFactory,
38 LanguageConverterFactory $languageConverterFactory
39 ) {
40 parent::__construct( 'Fewestrevisions' );
41 $this->setDatabaseProvider( $dbProvider );
42 $this->setLinkBatchFactory( $linkBatchFactory );
43 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
44 }
45
47 public function isExpensive() {
48 return true;
49 }
50
52 public function isSyndicated() {
53 return false;
54 }
55
57 public function getQueryInfo() {
58 return [
59 'tables' => [ 'revision', 'page' ],
60 'fields' => [
61 'namespace' => 'page_namespace',
62 'title' => 'page_title',
63 'value' => 'COUNT(*)',
64 ],
65 'conds' => [
66 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
67 'page_id = rev_page',
68 'page_is_redirect' => 0,
69 ],
70 'options' => [
71 'GROUP BY' => [ 'page_namespace', 'page_title' ]
72 ]
73 ];
74 }
75
77 protected function sortDescending() {
78 return false;
79 }
80
86 public function formatResult( $skin, $result ) {
87 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
88 if ( !$nt ) {
89 return Html::element(
90 'span',
91 [ 'class' => 'mw-invalidtitle' ],
92 Linker::getInvalidTitleDescription(
93 $this->getContext(),
94 $result->namespace,
95 $result->title
96 )
97 );
98 }
99 $linkRenderer = $this->getLinkRenderer();
100
101 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
102 $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
103
104 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
105 $redirect = isset( $result->redirect ) && $result->redirect ?
106 ' - ' . $this->msg( 'isredirect' )->escaped() : '';
107 $nlink = $linkRenderer->makeKnownLink(
108 $nt,
109 $nl,
110 [],
111 [ 'action' => 'history' ]
112 ) . $redirect;
113
114 return $this->getLanguage()->specialList( $plink, $nlink );
115 }
116
123 protected function preprocessResults( $db, $res ) {
124 $this->executeLBFromResultWrapper( $res );
125 }
126
128 protected function getGroupName() {
129 return 'maintenance';
130 }
131}
132
134class_alias( SpecialFewestRevisions::class, 'SpecialFewestRevisions' );
This class is a collection of static functions that serve two purposes:
Definition Html.php:44
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Some internal bits split of from Skin.php.
Definition Linker.php:47
Factory for LinkBatch objects to batch query page metadata.
The base class for all skins.
Definition Skin.php:54
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition QueryPage.php:77
setDatabaseProvider(IConnectionProvider $databaseProvider)
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
List articles with the fewest revisions.
__construct(private readonly NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isSyndicated()
Sometimes we don't want to build rss / atom feeds.to override bool
preprocessResults( $db, $res)
Cache page existence for performance.
sortDescending()
Override to sort by increasing values.to override bool
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Represents a title within MediaWiki.
Definition Title.php:69
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
The shared interface for all language converters.
Provide primary and replica IDatabase connections.
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)