mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 23:40:19 +00:00
Improve queries for testing on recent changes
- Use rc_source with values that we know we support. In particular, this drops categorization changes. - Filter on rc_log_type and rc_log_action (which itself may be shared across types). - Use the same query on both Special:AbuseFilter/test and Special:AbuseFilter/examine. Bug: T170574 Change-Id: I79b903b4424d3c15095a1e0491d35f6e005db0b8
This commit is contained in:
parent
dea61f1992
commit
efaae31263
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
abstract class AbuseFilterView extends ContextSource {
|
||||
public $mFilter, $mHistoryID, $mSubmit;
|
||||
|
@ -62,6 +63,34 @@ abstract class AbuseFilterView extends ContextSource {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IDatabase $db
|
||||
* @return string
|
||||
*/
|
||||
public function buildTestConditions( IDatabase $db ) {
|
||||
// If one of these is true, we're abusefilter compatible.
|
||||
return $db->makeList( [
|
||||
'rc_source' => [
|
||||
RecentChange::SRC_EDIT,
|
||||
RecentChange::SRC_NEW,
|
||||
],
|
||||
$db->makeList( [
|
||||
'rc_source' => RecentChange::SRC_LOG,
|
||||
$db->makeList( [
|
||||
$db->makeList( [
|
||||
'rc_log_type' => 'move',
|
||||
'rc_log_action' => 'move'
|
||||
], LIST_AND ),
|
||||
$db->makeList( [
|
||||
'rc_log_type' => 'newusers',
|
||||
'rc_log_action' => 'create'
|
||||
], LIST_AND ),
|
||||
// @todo: add upload and delete
|
||||
], LIST_OR ),
|
||||
], LIST_AND ),
|
||||
], LIST_OR );
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return bool
|
||||
|
@ -76,6 +105,7 @@ abstract class AbuseFilterView extends ContextSource {
|
|||
|
||||
return $canView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AbuseFilterChangesList extends OldChangesList {
|
||||
|
|
|
@ -222,12 +222,13 @@ class AbuseFilterExaminePager extends ReverseChronologicalPager {
|
|||
$this->mPage = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @fixme this is similar to AbuseFilterViewTestBatch::doTest
|
||||
*/
|
||||
function getQueryInfo() {
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
$conds = [
|
||||
'rc_user_text' => $this->mPage->mSearchUser,
|
||||
'rc_type != ' . RC_EXTERNAL
|
||||
];
|
||||
$conds = [];
|
||||
$conds['rc_user_text'] = $this->mPage->mSearchUser;
|
||||
|
||||
$startTS = strtotime( $this->mPage->mSearchPeriodStart );
|
||||
if ( $startTS ) {
|
||||
|
@ -238,13 +239,7 @@ class AbuseFilterExaminePager extends ReverseChronologicalPager {
|
|||
$conds[] = 'rc_timestamp<=' . $dbr->addQuotes( $dbr->timestamp( $endTS ) );
|
||||
}
|
||||
|
||||
// If one of these is true, we're abusefilter compatible.
|
||||
$compatConds = [
|
||||
'rc_this_oldid != 0',
|
||||
'rc_log_action' => [ 'move', 'create' ],
|
||||
];
|
||||
|
||||
$conds[] = $dbr->makeList( $compatConds, LIST_OR );
|
||||
$conds[] = $this->mPage->buildTestConditions( $dbr );
|
||||
|
||||
$info = [
|
||||
'tables' => 'recentchanges',
|
||||
|
|
|
@ -78,6 +78,9 @@ class AbuseFilterViewTestBatch extends AbuseFilterView {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fixme this is similar to AbuseFilterExaminePager::getQueryInfo
|
||||
*/
|
||||
function doTest() {
|
||||
// Quick syntax check.
|
||||
$out = $this->getOutput();
|
||||
|
@ -88,10 +91,8 @@ class AbuseFilterViewTestBatch extends AbuseFilterView {
|
|||
}
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
|
||||
$conds = [
|
||||
'rc_user_text' => $this->mTestUser,
|
||||
'rc_type != ' . RC_EXTERNAL
|
||||
];
|
||||
$conds = [];
|
||||
$conds['rc_user_text'] = $this->mTestUser;
|
||||
|
||||
if ( $this->mTestPeriodStart ) {
|
||||
$conds[] = 'rc_timestamp >= ' .
|
||||
|
@ -112,6 +113,8 @@ class AbuseFilterViewTestBatch extends AbuseFilterView {
|
|||
}
|
||||
}
|
||||
|
||||
$conds[] = $this->buildTestConditions( $dbr );
|
||||
|
||||
// Get our ChangesList
|
||||
$changesList = new AbuseFilterChangesList( $this->getSkin() );
|
||||
$output = $changesList->beginRecentChangesList();
|
||||
|
|
Loading…
Reference in a new issue