Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 42 |
|
0.00% |
0 / 9 |
CRAP | |
0.00% |
0 / 1 |
| SpecialAncientPages | |
0.00% |
0 / 41 |
|
0.00% |
0 / 9 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 4 |
|
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 / 23 |
|
0.00% |
0 / 1 |
2 | |||
| usesTimestamps | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sortDescending | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| preprocessResults | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| formatResult | |
0.00% |
0 / 8 |
|
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\Language\ILanguageConverter; |
| 10 | use MediaWiki\Languages\LanguageConverterFactory; |
| 11 | use MediaWiki\Page\LinkBatchFactory; |
| 12 | use MediaWiki\Skin\Skin; |
| 13 | use MediaWiki\SpecialPage\QueryPage; |
| 14 | use MediaWiki\Title\NamespaceInfo; |
| 15 | use MediaWiki\Title\Title; |
| 16 | use Wikimedia\HtmlArmor\HtmlArmor; |
| 17 | use Wikimedia\Rdbms\IConnectionProvider; |
| 18 | |
| 19 | /** |
| 20 | * Implements Special:Ancientpages |
| 21 | * |
| 22 | * @ingroup SpecialPage |
| 23 | */ |
| 24 | class SpecialAncientPages extends QueryPage { |
| 25 | |
| 26 | private ILanguageConverter $languageConverter; |
| 27 | |
| 28 | public function __construct( |
| 29 | private readonly NamespaceInfo $namespaceInfo, |
| 30 | IConnectionProvider $dbProvider, |
| 31 | LinkBatchFactory $linkBatchFactory, |
| 32 | LanguageConverterFactory $languageConverterFactory |
| 33 | ) { |
| 34 | parent::__construct( 'Ancientpages' ); |
| 35 | $this->setDatabaseProvider( $dbProvider ); |
| 36 | $this->setLinkBatchFactory( $linkBatchFactory ); |
| 37 | $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() ); |
| 38 | } |
| 39 | |
| 40 | /** @inheritDoc */ |
| 41 | public function isExpensive() { |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | /** @inheritDoc */ |
| 46 | public function isSyndicated() { |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | /** @inheritDoc */ |
| 51 | public function getQueryInfo() { |
| 52 | $tables = [ 'page', 'revision' ]; |
| 53 | $conds = [ |
| 54 | 'page_namespace' => $this->namespaceInfo->getContentNamespaces(), |
| 55 | 'page_is_redirect' => 0 |
| 56 | ]; |
| 57 | $joinConds = [ |
| 58 | 'revision' => [ |
| 59 | 'JOIN', [ |
| 60 | 'page_latest = rev_id' |
| 61 | ] |
| 62 | ], |
| 63 | ]; |
| 64 | |
| 65 | // Allow extensions to modify the query |
| 66 | $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds ); |
| 67 | |
| 68 | return [ |
| 69 | 'tables' => $tables, |
| 70 | 'fields' => [ |
| 71 | 'namespace' => 'page_namespace', |
| 72 | 'title' => 'page_title', |
| 73 | 'value' => 'rev_timestamp' |
| 74 | ], |
| 75 | 'conds' => $conds, |
| 76 | 'join_conds' => $joinConds |
| 77 | ]; |
| 78 | } |
| 79 | |
| 80 | /** @inheritDoc */ |
| 81 | public function usesTimestamps() { |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | /** @inheritDoc */ |
| 86 | protected function sortDescending() { |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | /** @inheritDoc */ |
| 91 | public function preprocessResults( $db, $res ) { |
| 92 | $this->executeLBFromResultWrapper( $res ); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * @param Skin $skin |
| 97 | * @param \stdClass $result Result row |
| 98 | * @return string |
| 99 | */ |
| 100 | public function formatResult( $skin, $result ) { |
| 101 | $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() ); |
| 102 | $title = Title::makeTitle( $result->namespace, $result->title ); |
| 103 | $linkRenderer = $this->getLinkRenderer(); |
| 104 | |
| 105 | $link = $linkRenderer->makeKnownLink( |
| 106 | $title, |
| 107 | new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) ) |
| 108 | ); |
| 109 | |
| 110 | return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) ); |
| 111 | } |
| 112 | |
| 113 | /** @inheritDoc */ |
| 114 | protected function getGroupName() { |
| 115 | return 'maintenance'; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /** @deprecated class alias since 1.41 */ |
| 120 | class_alias( SpecialAncientPages::class, 'SpecialAncientPages' ); |