MediaWiki master
SpecialFewestRevisions.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
11use MediaWiki\Languages\LanguageConverterFactory;
18use stdClass;
23
31
32 private NamespaceInfo $namespaceInfo;
33 private ILanguageConverter $languageConverter;
34
35 public function __construct(
36 NamespaceInfo $namespaceInfo,
37 IConnectionProvider $dbProvider,
38 LinkBatchFactory $linkBatchFactory,
39 LanguageConverterFactory $languageConverterFactory
40 ) {
41 parent::__construct( 'Fewestrevisions' );
42 $this->namespaceInfo = $namespaceInfo;
43 $this->setDatabaseProvider( $dbProvider );
44 $this->setLinkBatchFactory( $linkBatchFactory );
45 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
46 }
47
49 public function isExpensive() {
50 return true;
51 }
52
54 public function isSyndicated() {
55 return false;
56 }
57
59 public function getQueryInfo() {
60 return [
61 'tables' => [ 'revision', 'page' ],
62 'fields' => [
63 'namespace' => 'page_namespace',
64 'title' => 'page_title',
65 'value' => 'COUNT(*)',
66 ],
67 'conds' => [
68 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
69 'page_id = rev_page',
70 'page_is_redirect' => 0,
71 ],
72 'options' => [
73 'GROUP BY' => [ 'page_namespace', 'page_title' ]
74 ]
75 ];
76 }
77
79 protected function sortDescending() {
80 return false;
81 }
82
88 public function formatResult( $skin, $result ) {
89 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
90 if ( !$nt ) {
91 return Html::element(
92 'span',
93 [ 'class' => 'mw-invalidtitle' ],
94 Linker::getInvalidTitleDescription(
95 $this->getContext(),
96 $result->namespace,
97 $result->title
98 )
99 );
100 }
101 $linkRenderer = $this->getLinkRenderer();
102
103 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
104 $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
105
106 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
107 $redirect = isset( $result->redirect ) && $result->redirect ?
108 ' - ' . $this->msg( 'isredirect' )->escaped() : '';
109 $nlink = $linkRenderer->makeKnownLink(
110 $nt,
111 $nl,
112 [],
113 [ 'action' => 'history' ]
114 ) . $redirect;
115
116 return $this->getLanguage()->specialList( $plink, $nlink );
117 }
118
125 protected function preprocessResults( $db, $res ) {
126 $this->executeLBFromResultWrapper( $res );
127 }
128
130 protected function getGroupName() {
131 return 'maintenance';
132 }
133}
134
136class_alias( SpecialFewestRevisions::class, 'SpecialFewestRevisions' );
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
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:52
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.
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.
__construct(NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
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)