Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| SpecialWantedTemplates | |
0.00% |
0 / 28 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getQueryInfo | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getRecacheDB | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Copyright © 2008, Danny B. |
| 4 | * Based on SpecialWantedcategories.php by Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
| 5 | * makeWlhLink() taken from SpecialMostlinkedtemplates by Rob Church <robchur@gmail.com> |
| 6 | * |
| 7 | * @license GPL-2.0-or-later |
| 8 | * @file |
| 9 | */ |
| 10 | |
| 11 | namespace MediaWiki\Specials; |
| 12 | |
| 13 | use MediaWiki\Deferred\LinksUpdate\TemplateLinksTable; |
| 14 | use MediaWiki\Linker\LinksMigration; |
| 15 | use MediaWiki\Page\LinkBatchFactory; |
| 16 | use MediaWiki\SpecialPage\WantedQueryPage; |
| 17 | use Wikimedia\Rdbms\IConnectionProvider; |
| 18 | |
| 19 | /** |
| 20 | * List of the most wanted templates |
| 21 | * |
| 22 | * @ingroup SpecialPage |
| 23 | * @author Danny B. |
| 24 | */ |
| 25 | class SpecialWantedTemplates extends WantedQueryPage { |
| 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 | |
| 37 | /** @inheritDoc */ |
| 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 | |
| 61 | /** @inheritDoc */ |
| 62 | protected function getGroupName() { |
| 63 | return 'maintenance'; |
| 64 | } |
| 65 | |
| 66 | /** @inheritDoc */ |
| 67 | protected function getRecacheDB() { |
| 68 | return $this->getDatabaseProvider()->getReplicaDatabase( |
| 69 | TemplateLinksTable::VIRTUAL_DOMAIN, |
| 70 | 'vslow' |
| 71 | ); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Retain the old class name for backwards compatibility. |
| 77 | * @deprecated since 1.41 |
| 78 | */ |
| 79 | class_alias( SpecialWantedTemplates::class, 'SpecialWantedTemplates' ); |