Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 34 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
SpecialUnusedImages | |
0.00% |
0 / 33 |
|
0.00% |
0 / 8 |
110 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
isExpensive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sortDescending | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isSyndicated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getQueryInfo | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
6 | |||
usesTimestamps | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPageHeader | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * Implements Special:Unusedimages |
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\MainConfigNames; |
27 | use MediaWiki\SpecialPage\ImageQueryPage; |
28 | use Wikimedia\Rdbms\IConnectionProvider; |
29 | |
30 | /** |
31 | * A special page that lists unused images |
32 | * |
33 | * @ingroup SpecialPage |
34 | */ |
35 | class SpecialUnusedImages extends ImageQueryPage { |
36 | |
37 | /** |
38 | * @param IConnectionProvider $dbProvider |
39 | */ |
40 | public function __construct( IConnectionProvider $dbProvider ) { |
41 | parent::__construct( 'Unusedimages' ); |
42 | $this->setDatabaseProvider( $dbProvider ); |
43 | } |
44 | |
45 | public function isExpensive() { |
46 | return true; |
47 | } |
48 | |
49 | protected function sortDescending() { |
50 | return false; |
51 | } |
52 | |
53 | public function isSyndicated() { |
54 | return false; |
55 | } |
56 | |
57 | public function getQueryInfo() { |
58 | $retval = [ |
59 | 'tables' => [ 'image', 'imagelinks' ], |
60 | 'fields' => [ |
61 | 'namespace' => NS_FILE, |
62 | 'title' => 'img_name', |
63 | 'value' => 'img_timestamp', |
64 | ], |
65 | 'conds' => [ 'il_to' => null ], |
66 | 'join_conds' => [ 'imagelinks' => [ 'LEFT JOIN', 'il_to = img_name' ] ] |
67 | ]; |
68 | |
69 | if ( $this->getConfig()->get( MainConfigNames::CountCategorizedImagesAsUsed ) ) { |
70 | // Order is significant |
71 | $retval['tables'] = [ 'image', 'page', 'categorylinks', |
72 | 'imagelinks' ]; |
73 | $retval['conds']['page_namespace'] = NS_FILE; |
74 | $retval['conds']['cl_from'] = null; |
75 | $retval['conds'][] = 'img_name = page_title'; |
76 | $retval['join_conds']['categorylinks'] = [ |
77 | 'LEFT JOIN', 'cl_from = page_id' ]; |
78 | $retval['join_conds']['imagelinks'] = [ |
79 | 'LEFT JOIN', 'il_to = page_title' ]; |
80 | } |
81 | |
82 | return $retval; |
83 | } |
84 | |
85 | public function usesTimestamps() { |
86 | return true; |
87 | } |
88 | |
89 | protected function getPageHeader() { |
90 | if ( $this->getConfig()->get( MainConfigNames::CountCategorizedImagesAsUsed ) ) { |
91 | return $this->msg( |
92 | 'unusedimagestext-categorizedimgisused' |
93 | )->parseAsBlock(); |
94 | } |
95 | return $this->msg( 'unusedimagestext' )->parseAsBlock(); |
96 | } |
97 | |
98 | protected function getGroupName() { |
99 | return 'maintenance'; |
100 | } |
101 | } |
102 | |
103 | /** |
104 | * Retain the old class name for backwards compatibility. |
105 | * @deprecated since 1.41 |
106 | */ |
107 | class_alias( SpecialUnusedImages::class, 'SpecialUnusedImages' ); |