3 * Implements Special:Wantedfiles
5 * Copyright © 2008 Soxred93
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
23 * @ingroup SpecialPage
24 * @author Soxred93 <soxred93@gmail.com>
27 use MediaWiki\MediaWikiServices
;
30 * Querypage that lists the most wanted files
32 * @ingroup SpecialPage
34 class WantedFilesPage
extends WantedQueryPage
{
36 function __construct( $name = 'Wantedfiles' ) {
37 parent
::__construct( $name );
40 function getPageHeader() {
41 # Specifically setting to use "Wanted Files" (NS_MAIN) as title, so as to get what
42 # category would be used on main namespace pages, for those tricky wikipedia
43 # admins who like to do {{#ifeq:{{NAMESPACE}}|foo|bar|....}}.
44 $catMessage = $this->msg( 'broken-file-category' )
45 ->title( Title
::newFromText( "Wanted Files", NS_MAIN
) )
46 ->inContentLanguage();
48 if ( !$catMessage->isDisabled() ) {
49 $category = Title
::makeTitleSafe( NS_CATEGORY
, $catMessage->text() );
55 if ( !$this->likelyToHaveFalsePositives() ) {
56 // Additional messages for grep:
57 // wantedfiletext-cat-noforeign, wantedfiletext-nocat-noforeign
58 $noForeign = '-noforeign';
63 ->msg( 'wantedfiletext-cat' . $noForeign )
64 ->params( $category->getFullText() )
68 ->msg( 'wantedfiletext-nocat' . $noForeign )
74 * Whether foreign repos are likely to cause false positives
76 * In its own function to allow subclasses to override.
77 * @see SpecialWantedFilesGUOverride in GlobalUsage extension.
81 protected function likelyToHaveFalsePositives() {
82 return RepoGroup
::singleton()->hasForeignRepos();
86 * KLUGE: The results may contain false positives for files
87 * that exist e.g. in a shared repo. Setting this at least
88 * keeps them from showing up as redlinks in the output, even
89 * if it doesn't fix the real problem (T8220).
91 * @note could also have existing links here from broken file
95 function forceExistenceCheck() {
100 * Does the file exist?
102 * Use findFile() so we still think file namespace pages without files
103 * are missing, but valid file redirects and foreign files are ok.
105 * @param Title $title
108 protected function existenceCheck( Title
$title ) {
109 return (bool)MediaWikiServices
::getInstance()->getRepoGroup()->findFile( $title );
112 function getQueryInfo() {
122 'namespace' => NS_FILE
,
124 'value' => 'COUNT(*)'
127 'img1.img_name' => null,
128 // We also need to exclude file redirects
129 'img2.img_name' => null,
131 'options' => [ 'GROUP BY' => 'il_to' ],
133 'img1' => [ 'LEFT JOIN',
134 'il_to = img1.img_name'
136 'page' => [ 'LEFT JOIN', [
137 'il_to = page_title',
138 'page_namespace' => NS_FILE
,
140 'redirect' => [ 'LEFT JOIN', [
142 'rd_namespace' => NS_FILE
,
145 'img2' => [ 'LEFT JOIN',
146 'rd_title = img2.img_name'
152 protected function getGroupName() {
153 return 'maintenance';