Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 43
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
SpecialAncientPages
0.00% covered (danger)
0.00%
0 / 42
0.00% covered (danger)
0.00%
0 / 9
90
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 isExpensive
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isSyndicated
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getQueryInfo
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
2
 usesTimestamps
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 sortDescending
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 preprocessResults
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 formatResult
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 getGroupName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21namespace MediaWiki\Specials;
22
23use HtmlArmor;
24use MediaWiki\Cache\LinkBatchFactory;
25use MediaWiki\Language\ILanguageConverter;
26use MediaWiki\Languages\LanguageConverterFactory;
27use MediaWiki\SpecialPage\QueryPage;
28use MediaWiki\Title\NamespaceInfo;
29use MediaWiki\Title\Title;
30use Skin;
31use Wikimedia\Rdbms\IConnectionProvider;
32
33/**
34 * Implements Special:Ancientpages
35 *
36 * @ingroup SpecialPage
37 */
38class SpecialAncientPages extends QueryPage {
39
40    private NamespaceInfo $namespaceInfo;
41    private ILanguageConverter $languageConverter;
42
43    /**
44     * @param NamespaceInfo $namespaceInfo
45     * @param IConnectionProvider $dbProvider
46     * @param LinkBatchFactory $linkBatchFactory
47     * @param LanguageConverterFactory $languageConverterFactory
48     */
49    public function __construct(
50        NamespaceInfo $namespaceInfo,
51        IConnectionProvider $dbProvider,
52        LinkBatchFactory $linkBatchFactory,
53        LanguageConverterFactory $languageConverterFactory
54    ) {
55        parent::__construct( 'Ancientpages' );
56        $this->namespaceInfo = $namespaceInfo;
57        $this->setDatabaseProvider( $dbProvider );
58        $this->setLinkBatchFactory( $linkBatchFactory );
59        $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
60    }
61
62    public function isExpensive() {
63        return true;
64    }
65
66    public function isSyndicated() {
67        return false;
68    }
69
70    public function getQueryInfo() {
71        $tables = [ 'page', 'revision' ];
72        $conds = [
73            'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
74            'page_is_redirect' => 0
75        ];
76        $joinConds = [
77            'revision' => [
78                'JOIN', [
79                    'page_latest = rev_id'
80                ]
81            ],
82        ];
83
84        // Allow extensions to modify the query
85        $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds );
86
87        return [
88            'tables' => $tables,
89            'fields' => [
90                'namespace' => 'page_namespace',
91                'title' => 'page_title',
92                'value' => 'rev_timestamp'
93            ],
94            'conds' => $conds,
95            'join_conds' => $joinConds
96        ];
97    }
98
99    public function usesTimestamps() {
100        return true;
101    }
102
103    protected function sortDescending() {
104        return false;
105    }
106
107    public function preprocessResults( $db, $res ) {
108        $this->executeLBFromResultWrapper( $res );
109    }
110
111    /**
112     * @param Skin $skin
113     * @param \stdClass $result Result row
114     * @return string
115     */
116    public function formatResult( $skin, $result ) {
117        $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
118        $title = Title::makeTitle( $result->namespace, $result->title );
119        $linkRenderer = $this->getLinkRenderer();
120
121        $link = $linkRenderer->makeKnownLink(
122            $title,
123            new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) )
124        );
125
126        return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
127    }
128
129    protected function getGroupName() {
130        return 'maintenance';
131    }
132}
133
134/** @deprecated class alias since 1.41 */
135class_alias( SpecialAncientPages::class, 'SpecialAncientPages' );