Follow-up r90819: made XOR only work on two conditions per CR. Give a warning if...
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 28 Jun 2011 02:56:45 +0000 (02:56 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 28 Jun 2011 02:56:45 +0000 (02:56 +0000)
includes/Autopromote.php

index fa54edb..83f3c20 100644 (file)
@@ -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 ) ) {