Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 26
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
SpecialWantedTemplates
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getQueryInfo
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 1
2
 getGroupName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Implements Special:Wantedtemplates
4 *
5 * Copyright © 2008, Danny B.
6 * Based on SpecialWantedcategories.php by Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 * makeWlhLink() taken from SpecialMostlinkedtemplates by Rob Church <robchur@gmail.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 * @ingroup SpecialPage
26 * @author Danny B.
27 */
28
29namespace MediaWiki\Specials;
30
31use MediaWiki\Cache\LinkBatchFactory;
32use MediaWiki\Linker\LinksMigration;
33use MediaWiki\SpecialPage\WantedQueryPage;
34use Wikimedia\Rdbms\IConnectionProvider;
35
36/**
37 * A querypage to list the most wanted templates
38 *
39 * @ingroup SpecialPage
40 */
41class SpecialWantedTemplates extends WantedQueryPage {
42
43    private LinksMigration $linksMigration;
44
45    /**
46     * @param IConnectionProvider $dbProvider
47     * @param LinkBatchFactory $linkBatchFactory
48     * @param LinksMigration $linksMigration
49     */
50    public function __construct(
51        IConnectionProvider $dbProvider,
52        LinkBatchFactory $linkBatchFactory,
53        LinksMigration $linksMigration
54    ) {
55        parent::__construct( 'Wantedtemplates' );
56        $this->setDatabaseProvider( $dbProvider );
57        $this->setLinkBatchFactory( $linkBatchFactory );
58        $this->linksMigration = $linksMigration;
59    }
60
61    public function getQueryInfo() {
62        $queryInfo = $this->linksMigration->getQueryInfo( 'templatelinks' );
63        [ $ns, $title ] = $this->linksMigration->getTitleFields( 'templatelinks' );
64        return [
65            'tables' => array_merge( $queryInfo['tables'], [ 'page' ] ),
66            'fields' => [
67                'namespace' => $ns,
68                'title' => $title,
69                'value' => 'COUNT(*)'
70            ],
71            'conds' => [
72                'page_title' => null,
73                $ns => NS_TEMPLATE
74            ],
75            'options' => [ 'GROUP BY' => [ $ns, $title ] ],
76            'join_conds' => array_merge(
77                [ 'page' => [ 'LEFT JOIN',
78                    [ "page_namespace = $ns", "page_title = $title" ] ] ],
79                $queryInfo['joins']
80            )
81        ];
82    }
83
84    protected function getGroupName() {
85        return 'maintenance';
86    }
87}
88
89/**
90 * Retain the old class name for backwards compatibility.
91 * @deprecated since 1.41
92 */
93class_alias( SpecialWantedTemplates::class, 'SpecialWantedTemplates' );