2017-12-16 00:26:25 +00:00
|
|
|
<?php
|
|
|
|
|
2020-12-03 14:11:19 +00:00
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Pager;
|
|
|
|
|
2021-01-03 11:12:16 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterChangesList;
|
2021-04-03 14:08:17 +00:00
|
|
|
use MediaWiki\Linker\LinkRenderer;
|
2023-08-19 17:49:36 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2020-12-03 14:11:19 +00:00
|
|
|
use RecentChange;
|
|
|
|
use ReverseChronologicalPager;
|
|
|
|
use stdClass;
|
2021-04-03 14:08:17 +00:00
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
2020-11-29 10:53:29 +00:00
|
|
|
|
2017-12-16 00:26:25 +00:00
|
|
|
class AbuseFilterExaminePager extends ReverseChronologicalPager {
|
2018-11-08 14:34:32 +00:00
|
|
|
/**
|
|
|
|
* @var AbuseFilterChangesList Our changes list
|
|
|
|
*/
|
2021-04-03 14:08:17 +00:00
|
|
|
private $changesList;
|
2018-11-08 14:34:32 +00:00
|
|
|
/**
|
2021-04-03 14:08:17 +00:00
|
|
|
* @var Title
|
2018-11-08 14:34:32 +00:00
|
|
|
*/
|
2021-04-03 14:08:17 +00:00
|
|
|
private $title;
|
|
|
|
/**
|
|
|
|
* @var array Query conditions
|
|
|
|
*/
|
|
|
|
private $conds;
|
2020-10-31 14:27:20 +00:00
|
|
|
/**
|
|
|
|
* @var int Line number of the row, see RecentChange::$counter
|
|
|
|
*/
|
2021-04-03 14:08:17 +00:00
|
|
|
private $rcCounter;
|
2018-04-29 17:52:45 +00:00
|
|
|
|
2017-12-16 00:26:25 +00:00
|
|
|
/**
|
|
|
|
* @param AbuseFilterChangesList $changesList
|
2021-04-03 14:08:17 +00:00
|
|
|
* @param LinkRenderer $linkRenderer
|
|
|
|
* @param IDatabase $dbr
|
|
|
|
* @param Title $title
|
|
|
|
* @param array $conds
|
2017-12-16 00:26:25 +00:00
|
|
|
*/
|
2021-04-03 14:08:17 +00:00
|
|
|
public function __construct(
|
|
|
|
AbuseFilterChangesList $changesList,
|
|
|
|
LinkRenderer $linkRenderer,
|
|
|
|
IDatabase $dbr,
|
|
|
|
Title $title,
|
|
|
|
array $conds
|
|
|
|
) {
|
|
|
|
// Set database before parent constructor to avoid setting it there with wfGetDB
|
|
|
|
$this->mDb = $dbr;
|
|
|
|
parent::__construct( $changesList, $linkRenderer );
|
|
|
|
$this->changesList = $changesList;
|
|
|
|
$this->title = $title;
|
|
|
|
$this->conds = $conds;
|
2020-10-31 14:27:20 +00:00
|
|
|
$this->rcCounter = 1;
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
2018-04-04 21:14:25 +00:00
|
|
|
public function getQueryInfo() {
|
2021-04-19 05:18:47 +00:00
|
|
|
$rcQuery = RecentChange::getQueryInfo();
|
2023-06-12 15:08:25 +00:00
|
|
|
return [
|
2017-12-16 00:26:25 +00:00
|
|
|
'tables' => $rcQuery['tables'],
|
|
|
|
'fields' => $rcQuery['fields'],
|
2021-04-03 14:08:17 +00:00
|
|
|
'conds' => $this->conds,
|
2017-12-16 00:26:25 +00:00
|
|
|
'join_conds' => $rcQuery['joins'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @param stdClass $row
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function formatRow( $row ) {
|
2017-12-16 00:26:25 +00:00
|
|
|
$rc = RecentChange::newFromRow( $row );
|
2020-10-31 14:27:20 +00:00
|
|
|
$rc->counter = $this->rcCounter++;
|
2021-04-03 14:08:17 +00:00
|
|
|
return $this->changesList->recentChangesLine( $rc, false );
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2021-01-17 11:54:43 +00:00
|
|
|
* @codeCoverageIgnore Merely declarative
|
|
|
|
* @inheritDoc
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
|
|
|
public function getIndexField() {
|
2017-12-16 00:26:25 +00:00
|
|
|
return 'rc_id';
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2021-04-03 14:08:17 +00:00
|
|
|
* @codeCoverageIgnore Merely declarative
|
2018-04-04 21:14:25 +00:00
|
|
|
* @return Title
|
|
|
|
*/
|
|
|
|
public function getTitle() {
|
2021-04-03 14:08:17 +00:00
|
|
|
return $this->title;
|
2017-12-16 00:26:25 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getEmptyBody() {
|
2017-12-16 00:26:25 +00:00
|
|
|
return $this->msg( 'abusefilter-examine-noresults' )->parseAsBlock();
|
|
|
|
}
|
|
|
|
}
|