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