From 4ff2590688956d4f5b03621e262eaa59811276cc Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 28 Jun 2011 02:56:45 +0000 Subject: [PATCH] Follow-up r90819: made XOR only work on two conditions per CR. Give a warning if three or more given. --- includes/Autopromote.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/includes/Autopromote.php b/includes/Autopromote.php index fa54edbb72..83f3c20b5f 100644 --- a/includes/Autopromote.php +++ b/includes/Autopromote.php @@ -104,18 +104,11 @@ class Autopromote { return false; } elseif ( $cond[0] == '^' ) { // XOR (exactly one cond passes) - $res = false; - foreach ( array_slice( $cond, 1 ) as $subcond ) { - if ( self::recCheckCondition( $subcond, $user ) ) { - if ( $res ) { - return false; - } else { - $res = true; - } - } + if ( count( $cond ) > 3 ) { + wfWarn( 'recCheckCondition() given XOR ("^") condition on three or more conditions. Check your $wgAutopromote and $wgAutopromoteOnce settings.' ); } - - return $res; + return self::recCheckCondition( $cond[1], $user ) + xor self::recCheckCondition( $cond[2], $user ); } elseif ( $cond[0] == '!' ) { // NOT (no conds pass) foreach ( array_slice( $cond, 1 ) as $subcond ) { if ( self::recCheckCondition( $subcond, $user ) ) { -- 2.20.1