mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Support more log actions in testing interface
- Allow testing "move_redir" page moves. - Allow testing "create2" and "byemail" account creations. - Add remarks in the code that "autocreate" account creations cannot be tested since they are not in the recent changes. Change-Id: Idd38327df1477e1cba4396003a6c0f23cb75d276
This commit is contained in:
parent
67aea2aa7e
commit
92334b698b
|
@ -98,6 +98,7 @@ class ChangeTagger {
|
|||
|
||||
$logType = $recentChange->getAttribute( 'rc_log_type' ) ?: 'edit';
|
||||
if ( $logType === 'newusers' ) {
|
||||
// XXX: as of 1.43, the following is never true
|
||||
$action = $recentChange->getAttribute( 'rc_log_action' ) === 'autocreate' ?
|
||||
'autocreateaccount' :
|
||||
'createaccount';
|
||||
|
|
|
@ -68,7 +68,7 @@ class RCVariableGenerator extends VariableGenerator {
|
|||
* @return VariableHolder|null
|
||||
*/
|
||||
public function getVars(): ?VariableHolder {
|
||||
if ( $this->rc->getAttribute( 'rc_type' ) == RC_LOG ) {
|
||||
if ( $this->rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG ) {
|
||||
switch ( $this->rc->getAttribute( 'rc_log_type' ) ) {
|
||||
case 'move':
|
||||
$this->addMoveVars();
|
||||
|
@ -136,6 +136,7 @@ class RCVariableGenerator extends VariableGenerator {
|
|||
private function addCreateAccountVars(): self {
|
||||
$this->vars->setVar(
|
||||
'action',
|
||||
// XXX: as of 1.43, the following is never true
|
||||
$this->rc->getAttribute( 'rc_log_action' ) === 'autocreate'
|
||||
? 'autocreateaccount'
|
||||
: 'createaccount'
|
||||
|
|
|
@ -15,6 +15,7 @@ use MediaWiki\Title\Title;
|
|||
use OOUI;
|
||||
use RecentChange;
|
||||
use UnexpectedValueException;
|
||||
use Wikimedia\Assert\Assert;
|
||||
use Wikimedia\Rdbms\IExpression;
|
||||
use Wikimedia\Rdbms\IReadableDatabase;
|
||||
use Wikimedia\Rdbms\OrExpressionGroup;
|
||||
|
@ -24,29 +25,22 @@ abstract class AbuseFilterView extends ContextSource {
|
|||
|
||||
private const MAP_ACTION_TO_LOG_TYPE = [
|
||||
// action => [ rc_log_type, rc_log_action ]
|
||||
'move' => [ 'move', 'move' ],
|
||||
'createaccount' => [ 'newusers', [ 'create', 'autocreate' ] ],
|
||||
'move' => [ 'move', [ 'move', 'move_redir' ] ],
|
||||
'createaccount' => [ 'newusers', [ 'create', 'create2', 'byemail', 'autocreate' ] ],
|
||||
'delete' => [ 'delete', 'delete' ],
|
||||
'upload' => [ 'upload', [ 'upload', 'overwrite', 'revert' ] ],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var AbuseFilterPermissionManager
|
||||
*/
|
||||
protected $afPermManager;
|
||||
protected AbuseFilterPermissionManager $afPermManager;
|
||||
|
||||
/**
|
||||
* @var array The parameters of the current request
|
||||
*/
|
||||
protected $mParams;
|
||||
protected array $mParams;
|
||||
|
||||
/**
|
||||
* @var LinkRenderer
|
||||
*/
|
||||
protected $linkRenderer;
|
||||
protected LinkRenderer $linkRenderer;
|
||||
|
||||
/** @var string */
|
||||
protected $basePageName;
|
||||
protected string $basePageName;
|
||||
|
||||
/**
|
||||
* @param AbuseFilterPermissionManager $afPermManager
|
||||
|
@ -125,6 +119,7 @@ abstract class AbuseFilterView extends ContextSource {
|
|||
* @return IExpression
|
||||
*/
|
||||
public function buildTestConditions( IReadableDatabase $db, $action = false ) {
|
||||
Assert::parameterType( [ 'string', 'false' ], $action, '$action' );
|
||||
$editSources = [
|
||||
RecentChange::SRC_EDIT,
|
||||
RecentChange::SRC_NEW,
|
||||
|
|
Loading…
Reference in a new issue