Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 49 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| SpecialLonelyPages | |
0.00% |
0 / 48 |
|
0.00% |
0 / 8 |
110 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| getPageHeader | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sortDescending | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isExpensive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isSyndicated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getQueryInfo | |
0.00% |
0 / 34 |
|
0.00% |
0 / 1 |
6 | |||
| getOrderFields | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getGroupName | |
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\Languages\LanguageConverterFactory; |
| 10 | use MediaWiki\Linker\LinksMigration; |
| 11 | use MediaWiki\Page\LinkBatchFactory; |
| 12 | use MediaWiki\SpecialPage\PageQueryPage; |
| 13 | use MediaWiki\Title\NamespaceInfo; |
| 14 | use Wikimedia\Rdbms\IConnectionProvider; |
| 15 | |
| 16 | /** |
| 17 | * List of articles with no article linking to them, |
| 18 | * thus being lonely. |
| 19 | * |
| 20 | * @ingroup SpecialPage |
| 21 | */ |
| 22 | class SpecialLonelyPages extends PageQueryPage { |
| 23 | |
| 24 | private NamespaceInfo $namespaceInfo; |
| 25 | private LinksMigration $linksMigration; |
| 26 | |
| 27 | public function __construct( |
| 28 | NamespaceInfo $namespaceInfo, |
| 29 | IConnectionProvider $dbProvider, |
| 30 | LinkBatchFactory $linkBatchFactory, |
| 31 | LanguageConverterFactory $languageConverterFactory, |
| 32 | LinksMigration $linksMigration |
| 33 | ) { |
| 34 | parent::__construct( 'Lonelypages' ); |
| 35 | $this->namespaceInfo = $namespaceInfo; |
| 36 | $this->setDatabaseProvider( $dbProvider ); |
| 37 | $this->setLinkBatchFactory( $linkBatchFactory ); |
| 38 | $this->setLanguageConverter( $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ) ); |
| 39 | $this->linksMigration = $linksMigration; |
| 40 | } |
| 41 | |
| 42 | /** @inheritDoc */ |
| 43 | protected function getPageHeader() { |
| 44 | return $this->msg( 'lonelypagestext' )->parseAsBlock(); |
| 45 | } |
| 46 | |
| 47 | /** @inheritDoc */ |
| 48 | protected function sortDescending() { |
| 49 | return false; |
| 50 | } |
| 51 | |
| 52 | /** @inheritDoc */ |
| 53 | public function isExpensive() { |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | /** @inheritDoc */ |
| 58 | public function isSyndicated() { |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | /** @inheritDoc */ |
| 63 | public function getQueryInfo() { |
| 64 | $queryInfo = $this->linksMigration->getQueryInfo( 'pagelinks', 'pagelinks', 'LEFT JOIN' ); |
| 65 | $tables = [ 'page', 'linktarget', 'templatelinks', 'pagelinks' ]; |
| 66 | $conds = [ |
| 67 | 'pl_from' => null, |
| 68 | 'page_namespace' => $this->namespaceInfo->getContentNamespaces(), |
| 69 | 'page_is_redirect' => 0, |
| 70 | 'tl_from' => null, |
| 71 | ]; |
| 72 | $joinConds = [ |
| 73 | 'templatelinks' => [ 'LEFT JOIN', [ 'tl_target_id=lt_id' ] ], |
| 74 | 'linktarget' => [ |
| 75 | 'LEFT JOIN', [ |
| 76 | "lt_namespace = page_namespace", |
| 77 | "lt_title = page_title" |
| 78 | ] |
| 79 | ] |
| 80 | ]; |
| 81 | |
| 82 | if ( !in_array( 'linktarget', $queryInfo['tables'] ) ) { |
| 83 | $joinConds['pagelinks'] = [ |
| 84 | 'LEFT JOIN', [ |
| 85 | "pl_namespace = page_namespace", |
| 86 | "pl_title = page_title" |
| 87 | ] |
| 88 | ]; |
| 89 | } |
| 90 | |
| 91 | // Allow extensions to modify the query |
| 92 | $this->getHookRunner()->onLonelyPagesQuery( $tables, $conds, $joinConds ); |
| 93 | |
| 94 | return [ |
| 95 | 'tables' => $tables, |
| 96 | 'fields' => [ |
| 97 | 'namespace' => 'page_namespace', |
| 98 | 'title' => 'page_title', |
| 99 | ], |
| 100 | 'conds' => $conds, |
| 101 | 'join_conds' => array_merge( $joinConds, $queryInfo['joins'] ) |
| 102 | ]; |
| 103 | } |
| 104 | |
| 105 | /** @inheritDoc */ |
| 106 | protected function getOrderFields() { |
| 107 | // For some crazy reason ordering by a constant |
| 108 | // causes a filesort in MySQL 5 |
| 109 | if ( count( $this->namespaceInfo->getContentNamespaces() ) > 1 ) { |
| 110 | return [ 'page_namespace', 'page_title' ]; |
| 111 | } else { |
| 112 | return [ 'page_title' ]; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | /** @inheritDoc */ |
| 117 | protected function getGroupName() { |
| 118 | return 'maintenance'; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | /** @deprecated class alias since 1.41 */ |
| 123 | class_alias( SpecialLonelyPages::class, 'SpecialLonelyPages' ); |