Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
FlaggedRevsContributionsHooks | |
0.00% |
0 / 13 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
onSpecialContributions__getForm__filters | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
onContribsPager__getQueryInfo | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | // phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName |
3 | // phpcs:disable MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic |
4 | |
5 | namespace MediaWiki\Extension\FlaggedRevs\Backend; |
6 | |
7 | use MediaWiki\Hook\ContribsPager__getQueryInfoHook; |
8 | use MediaWiki\Hook\SpecialContributions__getForm__filtersHook; |
9 | |
10 | class FlaggedRevsContributionsHooks implements |
11 | SpecialContributions__getForm__filtersHook, |
12 | ContribsPager__getQueryInfoHook |
13 | { |
14 | |
15 | /** |
16 | * @inheritDoc |
17 | */ |
18 | public function onSpecialContributions__getForm__filters( $sp, &$filters ) { |
19 | $filters[] = [ |
20 | 'type' => 'check', |
21 | 'label-message' => 'flaggedrevs-contributions-filters-unreviewed-only', |
22 | 'name' => 'flaggedrevs-only-pending', |
23 | ]; |
24 | } |
25 | |
26 | /** |
27 | * @inheritDoc |
28 | */ |
29 | public function onContribsPager__getQueryInfo( $pager, &$queryInfo ) { |
30 | if ( $pager->getConfig()->get( 'FlaggedRevsProtection' ) ) { |
31 | return; |
32 | } |
33 | |
34 | if ( $pager->getContext()->getRequest()->getBool( 'flaggedrevs-only-pending' ) ) { |
35 | // only add the flaggedpages table if not already done by |
36 | // FlaggedRevsUIHooks::addToContribsQuery |
37 | if ( !in_array( 'flaggedrevs', $queryInfo['tables'] ) ) { |
38 | $queryInfo['tables'][] = 'flaggedpages'; |
39 | $queryInfo['join_conds']['flaggedpages'] = [ 'LEFT JOIN', "fp_page_id = rev_page" ]; |
40 | } |
41 | |
42 | // filter down to pending changes only |
43 | $queryInfo['conds'][] = '(fp_stable < rev_id AND fp_pending_since IS NOT NULL)' . |
44 | ' OR (fp_stable IS NULL)'; |
45 | } |
46 | } |
47 | } |