http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90819
Revision: 90819
Author: aaron
Date: 2011-06-26 04:50:24 +0000 (Sun, 26 Jun 2011)
Log Message:
-----------
Made '^' (XOR) in recCheckCondition() act as a one-hot detector. Before r28805,
XOR silently ignored subconds beyond the first two. After r28805, XOR passed
iff an odd number of subconds passed. It now passes iff exactly one subcond
passes. This should be more intuitive, as I highly doubt anyone using 3+
subconds was doing it correctly before.
Modified Paths:
--------------
trunk/phase3/includes/Autopromote.php
Modified: trunk/phase3/includes/Autopromote.php
===================================================================
--- trunk/phase3/includes/Autopromote.php 2011-06-26 04:36:02 UTC (rev
90818)
+++ trunk/phase3/includes/Autopromote.php 2011-06-26 04:50:24 UTC (rev
90819)
@@ -87,7 +87,7 @@
if ( is_array( $cond ) && count( $cond ) >= 2 && in_array(
$cond[0], $validOps ) ) {
# Recursive condition
- if ( $cond[0] == '&' ) {
+ if ( $cond[0] == '&' ) { // AND (all conds pass)
foreach ( array_slice( $cond, 1 ) as $subcond )
{
if ( !self::recCheckCondition(
$subcond, $user ) ) {
return false;
@@ -95,7 +95,7 @@
}
return true;
- } elseif ( $cond[0] == '|' ) {
+ } elseif ( $cond[0] == '|' ) { // OR (at least one cond
passes)
foreach ( array_slice( $cond, 1 ) as $subcond )
{
if ( self::recCheckCondition( $subcond,
$user ) ) {
return true;
@@ -103,18 +103,20 @@
}
return false;
- } elseif ( $cond[0] == '^' ) {
- $res = null;
+ } elseif ( $cond[0] == '^' ) { // XOR (exactly one cond
passes)
+ $res = false;
foreach ( array_slice( $cond, 1 ) as $subcond )
{
- if ( is_null( $res ) ) {
- $res = self::recCheckCondition(
$subcond, $user );
- } else {
- $res = ( $res xor
self::recCheckCondition( $subcond, $user ) );
+ if ( self::recCheckCondition( $subcond,
$user ) ) {
+ if ( $res ) {
+ return false;
+ } else {
+ $res = true;
+ }
}
}
return $res;
- } elseif ( $cond[0] == '!' ) {
+ } elseif ( $cond[0] == '!' ) { // NOT (no conds pass)
foreach ( array_slice( $cond, 1 ) as $subcond )
{
if ( self::recCheckCondition( $subcond,
$user ) ) {
return false;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs