Merge "Special:Upload should not crash on failing previews"
[mediawiki.git] / includes / specials / SpecialWantedpages.php
blobc37ecbd17adf9ae1aa3bfb47965bbb3417b6a716
1 <?php
2 /**
3 * Implements Special:Wantedpages
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.
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.
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
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * A special page that lists most linked pages that does not exist
27 * @ingroup SpecialPage
29 class WantedPagesPage extends WantedQueryPage {
31 function __construct( $name = 'Wantedpages' ) {
32 parent::__construct( $name );
35 function isIncludable() {
36 return true;
39 function execute( $par ) {
40 $inc = $this->including();
42 if ( $inc ) {
43 $this->limit = (int)$par;
44 $this->offset = 0;
46 $this->setListoutput( $inc );
47 $this->shownavigation = !$inc;
48 parent::execute( $par );
51 function getQueryInfo() {
52 $dbr = wfGetDB( DB_REPLICA );
53 $count = $this->getConfig()->get( 'WantedPagesThreshold' ) - 1;
54 $query = [
55 'tables' => [
56 'pagelinks',
57 'pg1' => 'page',
58 'pg2' => 'page'
60 'fields' => [
61 'namespace' => 'pl_namespace',
62 'title' => 'pl_title',
63 'value' => 'COUNT(*)'
65 'conds' => [
66 'pg1.page_namespace IS NULL',
67 'pl_namespace NOT IN (' . $dbr->makeList( [ NS_USER, NS_USER_TALK ] ) . ')',
68 'pg2.page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
70 'options' => [
71 'HAVING' => [
72 'COUNT(*) > ' . $dbr->addQuotes( $count ),
73 'COUNT(*) > SUM(pg2.page_is_redirect)'
75 'GROUP BY' => [ 'pl_namespace', 'pl_title' ]
77 'join_conds' => [
78 'pg1' => [
79 'LEFT JOIN', [
80 'pg1.page_namespace = pl_namespace',
81 'pg1.page_title = pl_title'
84 'pg2' => [ 'LEFT JOIN', 'pg2.page_id = pl_from' ]
87 // Replacement for the WantedPages::getSQL hook
88 Hooks::run( 'WantedPages::getQueryInfo', [ &$this, &$query ] );
90 return $query;
93 protected function getGroupName() {
94 return 'maintenance';