Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
FlaggedRevsContributionsHooks | |
0.00% |
0 / 16 |
|
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 / 11 |
|
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 | use Wikimedia\Rdbms\RawSQLExpression; |
10 | |
11 | class FlaggedRevsContributionsHooks implements |
12 | SpecialContributions__getForm__filtersHook, |
13 | ContribsPager__getQueryInfoHook |
14 | { |
15 | |
16 | /** |
17 | * @inheritDoc |
18 | */ |
19 | public function onSpecialContributions__getForm__filters( $sp, &$filters ) { |
20 | $filters[] = [ |
21 | 'type' => 'check', |
22 | 'label-message' => 'flaggedrevs-contributions-filters-unreviewed-only', |
23 | 'name' => 'flaggedrevs-only-pending', |
24 | ]; |
25 | } |
26 | |
27 | /** |
28 | * @inheritDoc |
29 | */ |
30 | public function onContribsPager__getQueryInfo( $pager, &$queryInfo ) { |
31 | if ( $pager->getConfig()->get( 'FlaggedRevsProtection' ) ) { |
32 | return; |
33 | } |
34 | |
35 | if ( $pager->getContext()->getRequest()->getBool( 'flaggedrevs-only-pending' ) ) { |
36 | // only add the flaggedpages table if not already done by |
37 | // FlaggedRevsUIHooks::addToContribsQuery |
38 | if ( !in_array( 'flaggedrevs', $queryInfo['tables'] ) ) { |
39 | $queryInfo['tables'][] = 'flaggedpages'; |
40 | $queryInfo['join_conds']['flaggedpages'] = [ 'LEFT JOIN', "fp_page_id = rev_page" ]; |
41 | } |
42 | |
43 | $dbr = $pager->getDatabase(); |
44 | // filter down to pending changes only |
45 | $queryInfo['conds'][] = $dbr->orExpr( [ |
46 | $dbr->expr( 'fp_pending_since', '!=', null )->andExpr( new RawSQLExpression( 'fp_stable < rev_id' ) ), |
47 | 'fp_stable' => null, |
48 | ] ); |
49 | } |
50 | } |
51 | } |