mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 06:03:49 +00:00
Merge "Deprecate addHolder for addHolders."
This commit is contained in:
commit
84487b86d8
|
@ -1869,7 +1869,7 @@ class AbuseFilter {
|
|||
// Add user data if the account was created by a registered user
|
||||
if ( $row->rc_user && $name != $row->rc_user_text ) {
|
||||
$user = User::newFromName( $row->rc_user_text );
|
||||
$vars->addHolder( self::generateUserVars( $user ) );
|
||||
$vars->addHolders( self::generateUserVars( $user ) );
|
||||
}
|
||||
|
||||
$vars->setVar( 'accountname', $name );
|
||||
|
@ -1891,9 +1891,11 @@ class AbuseFilter {
|
|||
$user->setName( $row->rc_user_text );
|
||||
}
|
||||
|
||||
$vars->addHolder( self::generateUserVars( $user ) );
|
||||
$vars->addHolders(
|
||||
self::generateUserVars( $user ),
|
||||
self::generateTitleVars( $title, 'ARTICLE' )
|
||||
);
|
||||
|
||||
$vars->addHolder( self::generateTitleVars( $title, 'ARTICLE' ) );
|
||||
$vars->setVar( 'ACTION', 'edit' );
|
||||
$vars->setVar( 'SUMMARY', $row->rc_comment );
|
||||
$vars->setVar( 'minor_edit', $row->rc_minor );
|
||||
|
@ -1908,7 +1910,7 @@ class AbuseFilter {
|
|||
$vars->setVar( 'old_wikitext', '' );
|
||||
}
|
||||
|
||||
$vars->addHolder( self::getEditVars( $title ) );
|
||||
$vars->addHolders( self::getEditVars( $title ) );
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
|
|
@ -114,8 +114,10 @@ class AbuseFilterHooks {
|
|||
return true;
|
||||
}
|
||||
|
||||
$vars->addHolder( AbuseFilter::generateUserVars( $user ) );
|
||||
$vars->addHolder( AbuseFilter::generateTitleVars( $title , 'ARTICLE' ) );
|
||||
$vars->addHolders(
|
||||
AbuseFilter::generateUserVars( $user ),
|
||||
AbuseFilter::generateTitleVars( $title , 'ARTICLE' )
|
||||
);
|
||||
|
||||
$vars->setVar( 'action', 'edit' );
|
||||
$vars->setVar( 'summary', $summary );
|
||||
|
@ -126,7 +128,7 @@ class AbuseFilterHooks {
|
|||
|
||||
// TODO: set old_content and new_content vars, use them
|
||||
|
||||
$vars->addHolder( AbuseFilter::getEditVars( $title, $page ) );
|
||||
$vars->addHolders( AbuseFilter::getEditVars( $title, $page ) );
|
||||
|
||||
$filter_result = AbuseFilter::filterAction( $vars, $title );
|
||||
|
||||
|
@ -242,12 +244,10 @@ class AbuseFilterHooks {
|
|||
$vars = new AbuseFilterVariableHolder;
|
||||
|
||||
global $wgUser;
|
||||
$vars->addHolder(
|
||||
AbuseFilterVariableHolder::merge(
|
||||
AbuseFilter::generateUserVars( $wgUser ),
|
||||
AbuseFilter::generateTitleVars( $oldTitle, 'MOVED_FROM' ),
|
||||
AbuseFilter::generateTitleVars( $newTitle, 'MOVED_TO' )
|
||||
)
|
||||
$vars->addHolders(
|
||||
AbuseFilter::generateUserVars( $wgUser ),
|
||||
AbuseFilter::generateTitleVars( $oldTitle, 'MOVED_FROM' ),
|
||||
AbuseFilter::generateTitleVars( $newTitle, 'MOVED_TO' )
|
||||
);
|
||||
$vars->setVar( 'SUMMARY', $reason );
|
||||
$vars->setVar( 'ACTION', 'move' );
|
||||
|
@ -270,8 +270,11 @@ class AbuseFilterHooks {
|
|||
$vars = new AbuseFilterVariableHolder;
|
||||
|
||||
global $wgUser;
|
||||
$vars->addHolder( AbuseFilter::generateUserVars( $wgUser ) );
|
||||
$vars->addHolder( AbuseFilter::generateTitleVars( $article->getTitle(), 'ARTICLE' ) );
|
||||
$vars->addHolders(
|
||||
AbuseFilter::generateUserVars( $wgUser ),
|
||||
AbuseFilter::generateTitleVars( $article->getTitle(), 'ARTICLE' )
|
||||
);
|
||||
|
||||
$vars->setVar( 'SUMMARY', $reason );
|
||||
$vars->setVar( 'ACTION', 'delete' );
|
||||
|
||||
|
@ -302,7 +305,7 @@ class AbuseFilterHooks {
|
|||
// new users won't be exposed
|
||||
global $wgUser;
|
||||
if ( $wgUser->getId() ) {
|
||||
$vars->addHolder( AbuseFilter::generateUserVars( $wgUser ) );
|
||||
$vars->addHolders( AbuseFilter::generateUserVars( $wgUser ) );
|
||||
}
|
||||
|
||||
$vars->setVar( 'ACTION', $autocreate ? 'autocreateaccount' : 'createaccount' );
|
||||
|
@ -500,11 +503,9 @@ class AbuseFilterHooks {
|
|||
|
||||
global $wgUser;
|
||||
$title = Title::makeTitle( NS_FILE, $saveName );
|
||||
$vars->addHolder(
|
||||
AbuseFilterVariableHolder::merge(
|
||||
AbuseFilter::generateUserVars( $wgUser ),
|
||||
AbuseFilter::generateTitleVars( $title, 'FILE' )
|
||||
)
|
||||
$vars->addHolders(
|
||||
AbuseFilter::generateUserVars( $wgUser ),
|
||||
AbuseFilter::generateTitleVars( $title, 'FILE' )
|
||||
);
|
||||
|
||||
$vars->setVar( 'ACTION', 'upload' );
|
||||
|
|
|
@ -698,7 +698,7 @@ class AbuseFilterParser {
|
|||
$this->setVar( $name, $var );
|
||||
}
|
||||
} elseif ( $vars instanceof AbuseFilterVariableHolder ) {
|
||||
$this->mVars->addHolder( $vars );
|
||||
$this->mVars->addHolders( $vars );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
class AbuseFilterVariableHolder {
|
||||
|
||||
var $mVars = array();
|
||||
|
||||
static $varBlacklist = array( 'context' );
|
||||
|
||||
/**
|
||||
|
@ -49,12 +51,9 @@ class AbuseFilterVariableHolder {
|
|||
/**
|
||||
* @return AbuseFilterVariableHolder
|
||||
*/
|
||||
static function merge() {
|
||||
public static function merge() {
|
||||
$newHolder = new AbuseFilterVariableHolder;
|
||||
|
||||
foreach ( func_get_args() as $addHolder ) {
|
||||
$newHolder->addHolder( $addHolder );
|
||||
}
|
||||
call_user_func_array( array( $newHolder, "addHolders" ), func_get_args() );
|
||||
|
||||
return $newHolder;
|
||||
}
|
||||
|
@ -62,12 +61,26 @@ class AbuseFilterVariableHolder {
|
|||
/**
|
||||
* @param $addHolder
|
||||
* @throws MWException
|
||||
* @deprecated use addHolders() instead
|
||||
*/
|
||||
function addHolder( $addHolder ) {
|
||||
if ( !is_object( $addHolder ) ) {
|
||||
throw new MWException( 'Invalid argument to AbuseFilterVariableHolder::addHolder' );
|
||||
public function addHolder( $addHolder ) {
|
||||
$this->addHolders( $addHolder );
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge any number of holders given as arguments into this holder.
|
||||
*
|
||||
* @throws MWException
|
||||
*/
|
||||
public function addHolders() {
|
||||
$holders = func_get_args();
|
||||
|
||||
foreach ( $holders as $addHolder ) {
|
||||
if ( !is_object( $addHolder ) ) {
|
||||
throw new MWException( 'Invalid argument to AbuseFilterVariableHolder::addHolders' );
|
||||
}
|
||||
$this->mVars = array_merge( $this->mVars, $addHolder->mVars );
|
||||
}
|
||||
$this->mVars = array_merge( $this->mVars, $addHolder->mVars );
|
||||
}
|
||||
|
||||
function __wakeup() {
|
||||
|
|
Loading…
Reference in a new issue