| 1 |
<?php |
| 2 |
|
| 3 |
3 |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
namespace MediaWiki\Specials; |
| 24 |
|
| 25 |
use MediaWiki\Cache\LinkBatchFactory; |
| 26 |
use MediaWiki\Page\PageReferenceValue; |
| 27 |
use MediaWiki\SpecialPage\WantedQueryPage; |
| 28 |
use MediaWiki\Title\Title; |
| 29 |
use RepoGroup; |
| 30 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
class SpecialWantedFiles extends WantedQueryPage { |
| 39 |
|
| 40 |
private RepoGroup $repoGroup; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public function __construct( |
| 48 |
RepoGroup $repoGroup, |
| 49 |
IConnectionProvider $dbProvider, |
| 50 |
LinkBatchFactory $linkBatchFactory |
| 51 |
) { |
| 52 |
parent::__construct( 'Wantedfiles' ); |
| 53 |
$this->repoGroup = $repoGroup; |
| 54 |
$this->setDatabaseProvider( $dbProvider ); |
| 55 |
$this->setLinkBatchFactory( $linkBatchFactory ); |
| 56 |
} |
| 57 |
|
| 58 |
protected function getPageHeader() { |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
$catMessage = $this->msg( 'broken-file-category' ) |
| 63 |
->page( PageReferenceValue::localReference( NS_MAIN, "Wanted Files" ) ) |
| 64 |
->inContentLanguage(); |
| 65 |
|
| 66 |
if ( !$catMessage->isDisabled() ) { |
| 67 |
$category = Title::makeTitleSafe( NS_CATEGORY, $catMessage->text() ); |
| 68 |
} else { |
| 69 |
$category = false; |
| 70 |
} |
| 71 |
|
| 72 |
$noForeign = ''; |
| 73 |
if ( !$this->likelyToHaveFalsePositives() ) { |
| 74 |
|
| 75 |
|
| 76 |
$noForeign = '-noforeign'; |
| 77 |
} |
| 78 |
|
| 79 |
if ( $category ) { |
| 80 |
return $this |
| 81 |
->msg( 'wantedfiletext-cat' . $noForeign ) |
| 82 |
->params( $category->getFullText() ) |
| 83 |
->parseAsBlock(); |
| 84 |
} else { |
| 85 |
return $this |
| 86 |
->msg( 'wantedfiletext-nocat' . $noForeign ) |
| 87 |
->parseAsBlock(); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
protected function likelyToHaveFalsePositives() { |
| 100 |
return $this->repoGroup->hasForeignRepos(); |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
protected function forceExistenceCheck() { |
| 114 |
return true; |
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
protected function existenceCheck( Title $title ) { |
| 127 |
return (bool)$this->repoGroup->findFile( $title ); |
| 128 |
} |
| 129 |
|
| 130 |
public function getQueryInfo() { |
| 131 |
return [ |
| 132 |
'tables' => [ |
| 133 |
'imagelinks', |
| 134 |
'page', |
| 135 |
'redirect', |
| 136 |
'img1' => 'image', |
| 137 |
'img2' => 'image', |
| 138 |
], |
| 139 |
'fields' => [ |
| 140 |
'namespace' => NS_FILE, |
| 141 |
'title' => 'il_to', |
| 142 |
'value' => 'COUNT(*)' |
| 143 |
], |
| 144 |
'conds' => [ |
| 145 |
'img1.img_name' => null, |
| 146 |
|
| 147 |
'img2.img_name' => null, |
| 148 |
], |
| 149 |
'options' => [ 'GROUP BY' => 'il_to' ], |
| 150 |
'join_conds' => [ |
| 151 |
'img1' => [ 'LEFT JOIN', |
| 152 |
'il_to = img1.img_name' |
| 153 |
], |
| 154 |
'page' => [ 'LEFT JOIN', [ |
| 155 |
'il_to = page_title', |
| 156 |
'page_namespace' => NS_FILE, |
| 157 |
] ], |
| 158 |
'redirect' => [ 'LEFT JOIN', [ |
| 159 |
'page_id = rd_from', |
| 160 |
'rd_namespace' => NS_FILE, |
| 161 |
'rd_interwiki' => '' |
| 162 |
] ], |
| 163 |
'img2' => [ 'LEFT JOIN', |
| 164 |
'rd_title = img2.img_name' |
| 165 |
] |
| 166 |
] |
| 167 |
]; |
| 168 |
} |
| 169 |
|
| 170 |
protected function getGroupName() { |
| 171 |
return 'maintenance'; |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
class_alias( SpecialWantedFiles::class, 'WantedFilesPage' ); |