mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 23:40:19 +00:00
Fix problems with prevention of double warnings
This commit is contained in:
parent
7dde267c91
commit
0e070fac7f
|
@ -378,6 +378,9 @@ class AbuseFilter {
|
|||
/** Returns an array [ list of actions taken by filter, error message to display, if any ] */
|
||||
public static function executeFilterActions( $filters, $title, $vars ) {
|
||||
wfProfileIn( __METHOD__ );
|
||||
static $blockingActions = array( 'block', 'rangeblock', 'degroup',
|
||||
'blockautopromote' );
|
||||
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
// Retrieve the consequences.
|
||||
$res = $dbr->select( array('abuse_filter_action', 'abuse_filter'), '*',
|
||||
|
@ -461,7 +464,9 @@ class AbuseFilter {
|
|||
unset( $actions['warn'] );
|
||||
}
|
||||
|
||||
if ( count($actions)>1 && !empty( $actions['disallow'] ) ) {
|
||||
// prevent double warnings
|
||||
if ( count( array_intersect( $actions, $blockingActions ) ) > 1 &&
|
||||
!empty( $actions['disallow'] ) ) {
|
||||
unset( $actions['disallow'] );
|
||||
}
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ class AFPUserVisibleException extends AFPException {
|
|||
}
|
||||
|
||||
class AbuseFilterParser {
|
||||
var $mParams, $mVars, $mCode, $mTokens, $mPos, $mCur;
|
||||
var $mParams, $mVars, $mCode, $mTokens, $mPos, $mCur, $mSubexpressions, $mDebug;
|
||||
|
||||
// length,lcase,ccnorm,rmdoubles,specialratio,rmspecials,norm,count
|
||||
static $mFunctions = array(
|
||||
|
@ -341,6 +341,8 @@ class AbuseFilterParser {
|
|||
$this->mTokens = array();
|
||||
$this->mVars = new AbuseFilterVariableHolder;
|
||||
$this->mPos = 0;
|
||||
$this->mDebug = false;
|
||||
$this->mSubexpressions = array();
|
||||
}
|
||||
|
||||
public function checkSyntax( $filter ) {
|
||||
|
@ -411,6 +413,28 @@ class AbuseFilterParser {
|
|||
return ( strlen($a) < strlen($b) ) ? -1 : 1;
|
||||
}
|
||||
|
||||
protected function createSubexpression( $value, $tokens, $type = null ) {
|
||||
if ($type)
|
||||
$data = new AFPData( $type, $value );
|
||||
else
|
||||
$data = AFPData::newFromPHPVar( $value );
|
||||
|
||||
if (!$this->mDebug)
|
||||
return $data;
|
||||
|
||||
if (!$this->mSubexpressions)
|
||||
$this->mSubexpressions = array();
|
||||
|
||||
$thisData = array(
|
||||
'tokens' => $tokens,
|
||||
'value' => $data,
|
||||
);
|
||||
|
||||
$this->mSubexpressions[] = $thisData;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Levels */
|
||||
|
||||
/** Handles unexpected characters after the expression */
|
||||
|
|
Loading…
Reference in a new issue