Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 51 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
SpecialWantedPages | |
0.00% |
0 / 50 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
isIncludable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
getQueryInfo | |
0.00% |
0 / 38 |
|
0.00% |
0 / 1 |
2 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Implements Special:Wantedpages |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License along |
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | * http://www.gnu.org/copyleft/gpl.html |
19 | * |
20 | * @file |
21 | * @ingroup SpecialPage |
22 | */ |
23 | |
24 | namespace MediaWiki\Specials; |
25 | |
26 | use MediaWiki\Cache\LinkBatchFactory; |
27 | use MediaWiki\Linker\LinksMigration; |
28 | use MediaWiki\MainConfigNames; |
29 | use MediaWiki\SpecialPage\WantedQueryPage; |
30 | use Wikimedia\Rdbms\IConnectionProvider; |
31 | |
32 | /** |
33 | * A special page that lists most linked pages that does not exist |
34 | * |
35 | * @ingroup SpecialPage |
36 | */ |
37 | class SpecialWantedPages extends WantedQueryPage { |
38 | |
39 | private LinksMigration $linksMigration; |
40 | |
41 | /** |
42 | * @param IConnectionProvider $dbProvider |
43 | * @param LinkBatchFactory $linkBatchFactory |
44 | */ |
45 | public function __construct( |
46 | IConnectionProvider $dbProvider, |
47 | LinkBatchFactory $linkBatchFactory, |
48 | LinksMigration $linksMigration |
49 | ) { |
50 | parent::__construct( 'Wantedpages' ); |
51 | $this->setDatabaseProvider( $dbProvider ); |
52 | $this->setLinkBatchFactory( $linkBatchFactory ); |
53 | $this->linksMigration = $linksMigration; |
54 | } |
55 | |
56 | public function isIncludable() { |
57 | return true; |
58 | } |
59 | |
60 | public function execute( $par ) { |
61 | $inc = $this->including(); |
62 | |
63 | if ( $inc ) { |
64 | $this->limit = (int)$par; |
65 | $this->offset = 0; |
66 | } |
67 | $this->shownavigation = !$inc; |
68 | parent::execute( $par ); |
69 | } |
70 | |
71 | public function getQueryInfo() { |
72 | $dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
73 | $count = $this->getConfig()->get( MainConfigNames::WantedPagesThreshold ) - 1; |
74 | [ $blNamespace, $blTitle ] = $this->linksMigration->getTitleFields( 'pagelinks' ); |
75 | $queryInfo = $this->linksMigration->getQueryInfo( 'pagelinks', 'pagelinks' ); |
76 | $query = [ |
77 | 'tables' => array_merge( $queryInfo['tables'], [ |
78 | 'pg1' => 'page', |
79 | 'pg2' => 'page' |
80 | ] ), |
81 | 'fields' => [ |
82 | 'namespace' => $blNamespace, |
83 | 'title' => $blTitle, |
84 | 'value' => 'COUNT(*)' |
85 | ], |
86 | 'conds' => [ |
87 | 'pg1.page_namespace' => null, |
88 | $dbr->expr( $blNamespace, '!=', [ NS_USER, NS_USER_TALK ] ), |
89 | $dbr->expr( 'pg2.page_namespace', '!=', NS_MEDIAWIKI ), |
90 | ], |
91 | 'options' => [ |
92 | 'HAVING' => [ |
93 | 'COUNT(*) > ' . $dbr->addQuotes( $count ), |
94 | 'COUNT(*) > SUM(pg2.page_is_redirect)' |
95 | ], |
96 | 'GROUP BY' => [ $blNamespace, $blTitle ] |
97 | ], |
98 | 'join_conds' => array_merge( [ |
99 | 'pg1' => [ |
100 | 'LEFT JOIN', [ |
101 | 'pg1.page_namespace = ' . $blNamespace, |
102 | 'pg1.page_title = ' . $blTitle |
103 | ] |
104 | ], |
105 | 'pg2' => [ 'LEFT JOIN', 'pg2.page_id = pl_from' ] |
106 | ], $queryInfo['joins'] ) |
107 | ]; |
108 | // Replacement for the WantedPages::getSQL hook |
109 | $this->getHookRunner()->onWantedPages__getQueryInfo( $this, $query ); |
110 | |
111 | return $query; |
112 | } |
113 | |
114 | protected function getGroupName() { |
115 | return 'maintenance'; |
116 | } |
117 | } |
118 | |
119 | /** |
120 | * Retain the old class name for backwards compatibility. |
121 | * @deprecated since 1.40 |
122 | */ |
123 | class_alias( SpecialWantedPages::class, 'WantedPagesPage' ); |