Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 36 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
StablePagesPager | |
0.00% |
0 / 36 |
|
0.00% |
0 / 7 |
210 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
30 | |||
formatRow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getQueryInfo | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
12 | |||
getIndexField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
doBatchLookups | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getStartBody | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEndBody | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | use MediaWiki\MediaWikiServices; |
4 | use MediaWiki\Pager\AlphabeticPager; |
5 | |
6 | /** |
7 | * Query to list out stable versions for a page |
8 | */ |
9 | class StablePagesPager extends AlphabeticPager { |
10 | /** @var StablePages */ |
11 | private $mForm; |
12 | |
13 | /** @var array */ |
14 | private $mConds; |
15 | |
16 | /** @var int|int[] */ |
17 | private $namespace; |
18 | |
19 | /** @var bool */ |
20 | private $indef; |
21 | |
22 | /** @var string|null */ |
23 | private $autoreview; |
24 | |
25 | /** |
26 | * @param StablePages $form |
27 | * @param array $conds |
28 | * @param int|null $namespace (null for "all") |
29 | * @param string $autoreview ('' for "all", 'none' for no restriction) |
30 | * @param bool $indef |
31 | */ |
32 | public function __construct( $form, $conds, $namespace, $autoreview, $indef ) { |
33 | $this->mForm = $form; |
34 | $this->mConds = $conds; |
35 | $this->indef = $indef; |
36 | // Must be content pages... |
37 | if ( !is_int( $namespace ) || !FlaggedRevs::isReviewNamespace( $namespace ) ) { |
38 | // Fallback to "all" |
39 | $namespace = FlaggedRevs::getReviewNamespaces(); |
40 | } |
41 | $this->namespace = $namespace; |
42 | if ( $autoreview === 'none' ) { |
43 | $autoreview = ''; // 'none' => '' |
44 | } elseif ( $autoreview === '' ) { |
45 | $autoreview = null; // '' => null |
46 | } |
47 | $this->autoreview = $autoreview; |
48 | parent::__construct(); |
49 | } |
50 | |
51 | /** |
52 | * @inheritDoc |
53 | */ |
54 | public function formatRow( $row ) { |
55 | return $this->mForm->formatRow( $row ); |
56 | } |
57 | |
58 | /** |
59 | * @inheritDoc |
60 | */ |
61 | public function getQueryInfo() { |
62 | $conds = $this->mConds; |
63 | $conds[] = 'page_id = fpc_page_id'; |
64 | $conds['fpc_override'] = 1; |
65 | if ( $this->autoreview !== null ) { |
66 | $conds['fpc_level'] = $this->autoreview; |
67 | } |
68 | $conds['page_namespace'] = $this->namespace; |
69 | // Be sure not to include expired items |
70 | if ( $this->indef ) { |
71 | $conds['fpc_expiry'] = $this->mDb->getInfinity(); |
72 | } else { |
73 | $conds[] = $this->mDb->expr( 'fpc_expiry', '>', $this->mDb->timestamp() ); |
74 | } |
75 | return [ |
76 | 'tables' => [ 'flaggedpage_config', 'page' ], |
77 | 'fields' => [ 'page_namespace', 'page_title', 'fpc_override', |
78 | 'fpc_expiry', 'fpc_page_id', 'fpc_level' ], |
79 | 'conds' => $conds, |
80 | 'options' => [] |
81 | ]; |
82 | } |
83 | |
84 | /** |
85 | * @return string |
86 | */ |
87 | public function getIndexField() { |
88 | return 'fpc_page_id'; |
89 | } |
90 | |
91 | /** |
92 | * @inheritDoc |
93 | */ |
94 | protected function doBatchLookups() { |
95 | $lb = MediaWikiServices::getInstance()->getLinkBatchFactory()->newLinkBatch(); |
96 | foreach ( $this->mResult as $row ) { |
97 | $lb->add( $row->page_namespace, $row->page_title ); |
98 | } |
99 | $lb->execute(); |
100 | } |
101 | |
102 | /** |
103 | * @return string HTML |
104 | */ |
105 | protected function getStartBody() { |
106 | return '<ul>'; |
107 | } |
108 | |
109 | /** |
110 | * @return string HTML |
111 | */ |
112 | protected function getEndBody() { |
113 | return '</ul>'; |
114 | } |
115 | } |