MediaWiki master
SpecialWantedTemplates.php
Go to the documentation of this file.
1<?php
11namespace MediaWiki\Specials;
12
18
26
27 public function __construct(
28 IConnectionProvider $dbProvider,
29 LinkBatchFactory $linkBatchFactory,
30 private readonly LinksMigration $linksMigration,
31 ) {
32 parent::__construct( 'Wantedtemplates' );
33 $this->setDatabaseProvider( $dbProvider );
34 $this->setLinkBatchFactory( $linkBatchFactory );
35 }
36
38 public function getQueryInfo() {
39 $queryInfo = $this->linksMigration->getQueryInfo( 'templatelinks' );
40 [ $ns, $title ] = $this->linksMigration->getTitleFields( 'templatelinks' );
41 return [
42 'tables' => array_merge( $queryInfo['tables'], [ 'page' ] ),
43 'fields' => [
44 'namespace' => $ns,
45 'title' => $title,
46 'value' => 'COUNT(*)'
47 ],
48 'conds' => [
49 'page_title' => null,
50 $ns => NS_TEMPLATE
51 ],
52 'options' => [ 'GROUP BY' => [ $ns, $title ] ],
53 'join_conds' => array_merge(
54 [ 'page' => [ 'LEFT JOIN',
55 [ "page_namespace = $ns", "page_title = $title" ] ] ],
56 $queryInfo['joins']
57 )
58 ];
59 }
60
62 protected function getGroupName() {
63 return 'maintenance';
64 }
65
67 protected function getRecacheDB() {
68 return $this->getDatabaseProvider()->getReplicaDatabase(
69 TemplateLinksTable::VIRTUAL_DOMAIN,
70 'vslow'
71 );
72 }
73}
74
79class_alias( SpecialWantedTemplates::class, 'SpecialWantedTemplates' );
const NS_TEMPLATE
Definition Defines.php:61
Service for compat reading of links tables.
Factory for LinkBatch objects to batch query page metadata.
setDatabaseProvider(IConnectionProvider $databaseProvider)
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Base class for a "wanted" query page like WantedPages, WantedTemplates, etc.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
__construct(IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, private readonly LinksMigration $linksMigration,)
getRecacheDB()
Get a DB connection to be used for slow recache queries.to override IReadableDatabase
Provide primary and replica IDatabase connections.