Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 36 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
| SpecialUnusedCategories | |
0.00% |
0 / 35 |
|
0.00% |
0 / 9 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| isExpensive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPageHeader | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getOrderFields | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getQueryInfo | |
0.00% |
0 / 24 |
|
0.00% |
0 / 1 |
2 | |||
| sortDescending | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| formatResult | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| preprocessResults | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials; |
| 8 | |
| 9 | use MediaWiki\Page\LinkBatchFactory; |
| 10 | use MediaWiki\Skin\Skin; |
| 11 | use MediaWiki\SpecialPage\QueryPage; |
| 12 | use MediaWiki\Title\Title; |
| 13 | use stdClass; |
| 14 | use Wikimedia\Rdbms\IConnectionProvider; |
| 15 | |
| 16 | /** |
| 17 | * Implements Special:Unusedcategories |
| 18 | * |
| 19 | * @ingroup SpecialPage |
| 20 | */ |
| 21 | class SpecialUnusedCategories extends QueryPage { |
| 22 | |
| 23 | public function __construct( |
| 24 | IConnectionProvider $dbProvider, |
| 25 | LinkBatchFactory $linkBatchFactory |
| 26 | ) { |
| 27 | parent::__construct( 'Unusedcategories' ); |
| 28 | $this->setDatabaseProvider( $dbProvider ); |
| 29 | $this->setLinkBatchFactory( $linkBatchFactory ); |
| 30 | } |
| 31 | |
| 32 | /** @inheritDoc */ |
| 33 | public function isExpensive() { |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | /** @inheritDoc */ |
| 38 | protected function getPageHeader() { |
| 39 | return $this->msg( 'unusedcategoriestext' )->parseAsBlock(); |
| 40 | } |
| 41 | |
| 42 | /** @inheritDoc */ |
| 43 | protected function getOrderFields() { |
| 44 | return [ 'title' ]; |
| 45 | } |
| 46 | |
| 47 | /** @inheritDoc */ |
| 48 | public function getQueryInfo() { |
| 49 | return [ |
| 50 | 'tables' => [ 'page', 'linktarget', 'categorylinks', 'page_props' ], |
| 51 | 'fields' => [ |
| 52 | 'namespace' => 'page_namespace', |
| 53 | 'title' => 'page_title', |
| 54 | ], |
| 55 | 'conds' => [ |
| 56 | 'cl_from' => null, |
| 57 | 'page_namespace' => NS_CATEGORY, |
| 58 | 'page_is_redirect' => 0, |
| 59 | 'pp_page' => null, |
| 60 | ], |
| 61 | 'join_conds' => [ |
| 62 | 'linktarget' => [ 'LEFT JOIN', [ |
| 63 | 'lt_title = page_title', |
| 64 | 'lt_namespace = page_namespace', |
| 65 | ] ], |
| 66 | 'categorylinks' => [ 'LEFT JOIN', 'cl_target_id = lt_id' ], |
| 67 | 'page_props' => [ 'LEFT JOIN', [ |
| 68 | 'page_id = pp_page', |
| 69 | 'pp_propname' => 'expectunusedcategory' |
| 70 | ] ] |
| 71 | ], |
| 72 | ]; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * A should come before Z (T32907) |
| 77 | * @return bool |
| 78 | */ |
| 79 | protected function sortDescending() { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @param Skin $skin |
| 85 | * @param stdClass $result Result row |
| 86 | * @return string |
| 87 | */ |
| 88 | public function formatResult( $skin, $result ) { |
| 89 | $title = Title::makeTitle( NS_CATEGORY, $result->title ); |
| 90 | |
| 91 | return $this->getLinkRenderer()->makeLink( $title, $title->getText() ); |
| 92 | } |
| 93 | |
| 94 | /** @inheritDoc */ |
| 95 | protected function getGroupName() { |
| 96 | return 'maintenance'; |
| 97 | } |
| 98 | |
| 99 | /** @inheritDoc */ |
| 100 | public function preprocessResults( $db, $res ) { |
| 101 | $this->executeLBFromResultWrapper( $res ); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Retain the old class name for backwards compatibility. |
| 107 | * @deprecated since 1.41 |
| 108 | */ |
| 109 | class_alias( SpecialUnusedCategories::class, 'SpecialUnusedCategories' ); |