r90931 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90930‎ | r90931 | r90932 >
Date:02:56, 28 June 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Follow-up r90819: made XOR only work on two conditions per CR. Give a warning if three or more given.
Modified paths:
  • /trunk/phase3/includes/Autopromote.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Autopromote.php
@@ -104,18 +104,11 @@
105105
106106 return false;
107107 } elseif ( $cond[0] == '^' ) { // XOR (exactly one cond passes)
108 - $res = false;
109 - foreach ( array_slice( $cond, 1 ) as $subcond ) {
110 - if ( self::recCheckCondition( $subcond, $user ) ) {
111 - if ( $res ) {
112 - return false;
113 - } else {
114 - $res = true;
115 - }
116 - }
 108+ if ( count( $cond ) > 3 ) {
 109+ wfWarn( 'recCheckCondition() given XOR ("^") condition on three or more conditions. Check your $wgAutopromote and $wgAutopromoteOnce settings.' );
117110 }
118 -
119 - return $res;
 111+ return self::recCheckCondition( $cond[1], $user )
 112+ xor self::recCheckCondition( $cond[2], $user );
120113 } elseif ( $cond[0] == '!' ) { // NOT (no conds pass)
121114 foreach ( array_slice( $cond, 1 ) as $subcond ) {
122115 if ( self::recCheckCondition( $subcond, $user ) ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90819Made '^' (XOR) in recCheckCondition() act as a one-hot detector. Before r2880...aaron04:50, 26 June 2011

Comments

#Comment by 😂 (talk | contribs)   21:42, 20 July 2011

Not a fan of wfWarn(), but otherwise ok.

#Comment by Aaron Schulz (talk | contribs)   21:43, 20 July 2011

I wasn't sure what was most appropriate there.

#Comment by 😂 (talk | contribs)   21:46, 20 July 2011

Exception perhaps? The main reason I'm against warnings is people tend to disable and ignore them.

Status & tagging log