Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
AbuseFilterExaminePager
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 4
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 getQueryInfo
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 formatRow
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 getIndexField
n/a
0 / 0
n/a
0 / 0
1
 getTitle
n/a
0 / 0
n/a
0 / 0
1
 getEmptyBody
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\AbuseFilter\Pager;
4
5use MediaWiki\Extension\AbuseFilter\AbuseFilterChangesList;
6use MediaWiki\Linker\LinkRenderer;
7use MediaWiki\Pager\ReverseChronologicalPager;
8use MediaWiki\Title\Title;
9use RecentChange;
10use stdClass;
11use Wikimedia\Rdbms\IReadableDatabase;
12
13class AbuseFilterExaminePager extends ReverseChronologicalPager {
14    /**
15     * @var AbuseFilterChangesList Our changes list
16     */
17    private $changesList;
18    /**
19     * @var Title
20     */
21    private $title;
22    /**
23     * @var array Query conditions
24     */
25    private $conds;
26    /**
27     * @var int Line number of the row, see RecentChange::$counter
28     */
29    private $rcCounter;
30
31    /**
32     * @param AbuseFilterChangesList $changesList
33     * @param LinkRenderer $linkRenderer
34     * @param IReadableDatabase $dbr
35     * @param Title $title
36     * @param array $conds
37     */
38    public function __construct(
39        AbuseFilterChangesList $changesList,
40        LinkRenderer $linkRenderer,
41        IReadableDatabase $dbr,
42        Title $title,
43        array $conds
44    ) {
45        // Set database before parent constructor to avoid setting it there
46        $this->mDb = $dbr;
47        parent::__construct( $changesList, $linkRenderer );
48        $this->changesList = $changesList;
49        $this->title = $title;
50        $this->conds = $conds;
51        $this->rcCounter = 1;
52    }
53
54    /**
55     * @return array
56     */
57    public function getQueryInfo() {
58        $rcQuery = RecentChange::getQueryInfo();
59        return [
60            'tables' => $rcQuery['tables'],
61            'fields' => $rcQuery['fields'],
62            'conds' => $this->conds,
63            'join_conds' => $rcQuery['joins'],
64        ];
65    }
66
67    /**
68     * @param stdClass $row
69     * @return string
70     */
71    public function formatRow( $row ) {
72        $rc = RecentChange::newFromRow( $row );
73        $rc->counter = $this->rcCounter++;
74        return $this->changesList->recentChangesLine( $rc, false );
75    }
76
77    /**
78     * @codeCoverageIgnore Merely declarative
79     * @inheritDoc
80     */
81    public function getIndexField() {
82        return 'rc_id';
83    }
84
85    /**
86     * @codeCoverageIgnore Merely declarative
87     * @return Title
88     */
89    public function getTitle() {
90        return $this->title;
91    }
92
93    /**
94     * @return string
95     */
96    public function getEmptyBody() {
97        return $this->msg( 'abusefilter-examine-noresults' )->parseAsBlock();
98    }
99}