Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 54 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SpecialWantedPages | |
0.00% |
0 / 53 |
|
0.00% |
0 / 6 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| isIncludable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| getQueryInfo | |
0.00% |
0 / 38 |
|
0.00% |
0 / 1 |
2 | |||
| getRecacheDB | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 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\Deferred\LinksUpdate\PageLinksTable; |
| 10 | use MediaWiki\Linker\LinksMigration; |
| 11 | use MediaWiki\MainConfigNames; |
| 12 | use MediaWiki\Page\LinkBatchFactory; |
| 13 | use MediaWiki\SpecialPage\WantedQueryPage; |
| 14 | use Wikimedia\Rdbms\IConnectionProvider; |
| 15 | |
| 16 | /** |
| 17 | * List of the most-linked pages that do not exist. |
| 18 | * |
| 19 | * @ingroup SpecialPage |
| 20 | */ |
| 21 | class SpecialWantedPages extends WantedQueryPage { |
| 22 | |
| 23 | public function __construct( |
| 24 | IConnectionProvider $dbProvider, |
| 25 | LinkBatchFactory $linkBatchFactory, |
| 26 | private readonly LinksMigration $linksMigration |
| 27 | ) { |
| 28 | parent::__construct( 'Wantedpages' ); |
| 29 | $this->setDatabaseProvider( $dbProvider ); |
| 30 | $this->setLinkBatchFactory( $linkBatchFactory ); |
| 31 | } |
| 32 | |
| 33 | /** @inheritDoc */ |
| 34 | public function isIncludable() { |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | /** @inheritDoc */ |
| 39 | public function execute( $par ) { |
| 40 | $inc = $this->including(); |
| 41 | |
| 42 | if ( $inc ) { |
| 43 | $this->limit = (int)$par; |
| 44 | $this->offset = 0; |
| 45 | } |
| 46 | $this->shownavigation = !$inc; |
| 47 | parent::execute( $par ); |
| 48 | } |
| 49 | |
| 50 | /** @inheritDoc */ |
| 51 | public function getQueryInfo() { |
| 52 | $dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
| 53 | $count = $this->getConfig()->get( MainConfigNames::WantedPagesThreshold ) - 1; |
| 54 | [ $blNamespace, $blTitle ] = $this->linksMigration->getTitleFields( 'pagelinks' ); |
| 55 | $queryInfo = $this->linksMigration->getQueryInfo( 'pagelinks', 'pagelinks' ); |
| 56 | $query = [ |
| 57 | 'tables' => array_merge( $queryInfo['tables'], [ |
| 58 | 'pg1' => 'page', |
| 59 | 'pg2' => 'page' |
| 60 | ] ), |
| 61 | 'fields' => [ |
| 62 | 'namespace' => $blNamespace, |
| 63 | 'title' => $blTitle, |
| 64 | 'value' => 'COUNT(*)' |
| 65 | ], |
| 66 | 'conds' => [ |
| 67 | 'pg1.page_namespace' => null, |
| 68 | $dbr->expr( $blNamespace, '!=', [ NS_USER, NS_USER_TALK ] ), |
| 69 | $dbr->expr( 'pg2.page_namespace', '!=', NS_MEDIAWIKI ), |
| 70 | ], |
| 71 | 'options' => [ |
| 72 | 'HAVING' => [ |
| 73 | 'COUNT(*) > ' . $dbr->addQuotes( $count ), |
| 74 | 'COUNT(*) > SUM(pg2.page_is_redirect)' |
| 75 | ], |
| 76 | 'GROUP BY' => [ $blNamespace, $blTitle ] |
| 77 | ], |
| 78 | 'join_conds' => array_merge( [ |
| 79 | 'pg1' => [ |
| 80 | 'LEFT JOIN', [ |
| 81 | 'pg1.page_namespace = ' . $blNamespace, |
| 82 | 'pg1.page_title = ' . $blTitle |
| 83 | ] |
| 84 | ], |
| 85 | 'pg2' => [ 'LEFT JOIN', 'pg2.page_id = pl_from' ] |
| 86 | ], $queryInfo['joins'] ) |
| 87 | ]; |
| 88 | // Replacement for the WantedPages::getSQL hook |
| 89 | $this->getHookRunner()->onWantedPages__getQueryInfo( $this, $query ); |
| 90 | |
| 91 | return $query; |
| 92 | } |
| 93 | |
| 94 | /** @inheritDoc */ |
| 95 | protected function getRecacheDB() { |
| 96 | return $this->getDatabaseProvider()->getReplicaDatabase( |
| 97 | PageLinksTable::VIRTUAL_DOMAIN, |
| 98 | 'vslow' |
| 99 | ); |
| 100 | } |
| 101 | |
| 102 | /** @inheritDoc */ |
| 103 | protected function getGroupName() { |
| 104 | return 'maintenance'; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Retain the old class name for backwards compatibility. |
| 110 | * @deprecated since 1.40 |
| 111 | */ |
| 112 | class_alias( SpecialWantedPages::class, 'WantedPagesPage' ); |