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