MediaWiki master
SpecialWantedTemplates.php
Go to the documentation of this file.
1<?php
11namespace MediaWiki\Specials;
12
13use MediaWiki\Cache\LinkBatchFactory;
18
26
27 private LinksMigration $linksMigration;
28
29 public function __construct(
30 IConnectionProvider $dbProvider,
31 LinkBatchFactory $linkBatchFactory,
32 LinksMigration $linksMigration
33 ) {
34 parent::__construct( 'Wantedtemplates' );
35 $this->setDatabaseProvider( $dbProvider );
36 $this->setLinkBatchFactory( $linkBatchFactory );
37 $this->linksMigration = $linksMigration;
38 }
39
41 public function getQueryInfo() {
42 $queryInfo = $this->linksMigration->getQueryInfo( 'templatelinks' );
43 [ $ns, $title ] = $this->linksMigration->getTitleFields( 'templatelinks' );
44 return [
45 'tables' => array_merge( $queryInfo['tables'], [ 'page' ] ),
46 'fields' => [
47 'namespace' => $ns,
48 'title' => $title,
49 'value' => 'COUNT(*)'
50 ],
51 'conds' => [
52 'page_title' => null,
53 $ns => NS_TEMPLATE
54 ],
55 'options' => [ 'GROUP BY' => [ $ns, $title ] ],
56 'join_conds' => array_merge(
57 [ 'page' => [ 'LEFT JOIN',
58 [ "page_namespace = $ns", "page_title = $title" ] ] ],
59 $queryInfo['joins']
60 )
61 ];
62 }
63
65 protected function getGroupName() {
66 return 'maintenance';
67 }
68
70 protected function getRecacheDB() {
71 return $this->getDatabaseProvider()->getReplicaDatabase(
72 TemplateLinksTable::VIRTUAL_DOMAIN,
73 'vslow'
74 );
75 }
76}
77
82class_alias( SpecialWantedTemplates::class, 'SpecialWantedTemplates' );
const NS_TEMPLATE
Definition Defines.php:61
Service for compat reading of links tables.
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...
getRecacheDB()
Get a DB connection to be used for slow recache queries.to override IReadableDatabase
__construct(IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LinksMigration $linksMigration)
Provide primary and replica IDatabase connections.