| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Specials; |
| 22 |
|
| 23 |
use MediaWiki\Cache\LinkBatchFactory; |
| 24 |
use MediaWiki\Linker\LinksMigration; |
| 25 |
use MediaWiki\MainConfigNames; |
| 26 |
use MediaWiki\SpecialPage\WantedQueryPage; |
| 27 |
use Wikimedia\Rdbms\IConnectionProvider; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
class SpecialWantedPages extends WantedQueryPage { |
| 35 |
|
| 36 |
private LinksMigration $linksMigration; |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public function __construct( |
| 43 |
IConnectionProvider $dbProvider, |
| 44 |
LinkBatchFactory $linkBatchFactory, |
| 45 |
LinksMigration $linksMigration |
| 46 |
) { |
| 47 |
parent::__construct( 'Wantedpages' ); |
| 48 |
$this->setDatabaseProvider( $dbProvider ); |
| 49 |
$this->setLinkBatchFactory( $linkBatchFactory ); |
| 50 |
$this->linksMigration = $linksMigration; |
| 51 |
} |
| 52 |
|
| 53 |
public function isIncludable() { |
| 54 |
return true; |
| 55 |
} |
| 56 |
|
| 57 |
public function execute( $par ) { |
| 58 |
$inc = $this->including(); |
| 59 |
|
| 60 |
if ( $inc ) { |
| 61 |
$this->limit = (int)$par; |
| 62 |
$this->offset = 0; |
| 63 |
} |
| 64 |
$this->shownavigation = !$inc; |
| 65 |
parent::execute( $par ); |
| 66 |
} |
| 67 |
|
| 68 |
public function getQueryInfo() { |
| 69 |
$dbr = $this->getDatabaseProvider()->getReplicaDatabase(); |
| 70 |
$count = $this->getConfig()->get( MainConfigNames::WantedPagesThreshold ) - 1; |
| 71 |
[ $blNamespace, $blTitle ] = $this->linksMigration->getTitleFields( 'pagelinks' ); |
| 72 |
$queryInfo = $this->linksMigration->getQueryInfo( 'pagelinks', 'pagelinks' ); |
| 73 |
$query = [ |
| 74 |
'tables' => array_merge( $queryInfo['tables'], [ |
| 75 |
'pg1' => 'page', |
| 76 |
'pg2' => 'page' |
| 77 |
] ), |
| 78 |
'fields' => [ |
| 79 |
'namespace' => $blNamespace, |
| 80 |
'title' => $blTitle, |
| 81 |
'value' => 'COUNT(*)' |
| 82 |
], |
| 83 |
'conds' => [ |
| 84 |
'pg1.page_namespace' => null, |
| 85 |
$dbr->expr( $blNamespace, '!=', [ NS_USER, NS_USER_TALK ] ), |
| 86 |
$dbr->expr( 'pg2.page_namespace', '!=', NS_MEDIAWIKI ), |
| 87 |
], |
| 88 |
'options' => [ |
| 89 |
'HAVING' => [ |
| 90 |
'COUNT(*) > ' . $dbr->addQuotes( $count ), |
| 91 |
'COUNT(*) > SUM(pg2.page_is_redirect)' |
| 92 |
], |
| 93 |
'GROUP BY' => [ $blNamespace, $blTitle ] |
| 94 |
], |
| 95 |
'join_conds' => array_merge( [ |
| 96 |
'pg1' => [ |
| 97 |
'LEFT JOIN', [ |
| 98 |
'pg1.page_namespace = ' . $blNamespace, |
| 99 |
'pg1.page_title = ' . $blTitle |
| 100 |
] |
| 101 |
], |
| 102 |
'pg2' => [ 'LEFT JOIN', 'pg2.page_id = pl_from' ] |
| 103 |
], $queryInfo['joins'] ) |
| 104 |
]; |
| 105 |
|
| 106 |
$this->getHookRunner()->onWantedPages__getQueryInfo( $this, $query ); |
| 107 |
|
| 108 |
return $query; |
| 109 |
} |
| 110 |
|
| 111 |
protected function getGroupName() { |
| 112 |
return 'maintenance'; |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
class_alias( SpecialWantedPages::class, 'WantedPagesPage' ); |