r84581 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84580‎ | r84581 | r84582 >
Date:23:07, 22 March 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Followup r84575, bug 27470

Inverse all the booleans in matches

Previous fix was naieve, and just ended up picking the first regex and dieing with that
Modified paths:
  • /trunk/extensions/TitleBlacklist/TitleBlacklist.list.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TitleBlacklist/TitleBlacklist.list.php
@@ -104,7 +104,7 @@
105105
106106 return '';
107107 }
108 -
 108+
109109 /**
110110 * Parse blacklist from a string
111111 *
@@ -115,8 +115,7 @@
116116 wfProfileIn( __METHOD__ );
117117 $lines = preg_split( "/\r?\n/", $list );
118118 $result = array();
119 - foreach ( $lines as $line )
120 - {
 119+ foreach ( $lines as $line ) {
121120 $line = TitleBlacklistEntry :: newFromString( $line );
122121 if ( $line ) {
123122 $result[] = $line;
@@ -164,7 +163,7 @@
165164 if( $this->isWhitelisted( $title, $action ) ) {
166165 return false;
167166 }
168 - return $item;
 167+ return $item; // "returning true"
169168 }
170169 }
171170 return false;
@@ -254,8 +253,9 @@
255254 foreach( $blacklist as $e ) {
256255 wfSuppressWarnings();
257256 $regex = $e->getRegex();
258 - if( preg_match( "/{$regex}/u", '' ) === false )
 257+ if( preg_match( "/{$regex}/u", '' ) === false ) {
259258 $badEntries[] = $e->getRaw();
 259+ }
260260 wfRestoreWarnings();
261261 }
262262 return $badEntries;
@@ -304,7 +304,8 @@
305305 *
306306 * @param $title Title to check
307307 * @param $action %Action to check
308 - * @return TRUE if the user can; otherwise FALSE
 308+ * @return TRUE if the the regex matches the title, and is not overridden
 309+ * else if it doesn't match (or was overridden)
309310 */
310311 public function matches( $title, $action ) {
311312 wfSuppressWarnings();
@@ -314,24 +315,24 @@
315316 global $wgUser;
316317 if( $match ) {
317318 if( isset( $this->mParams['autoconfirmed'] ) && $wgUser->isAllowed( 'autoconfirmed' ) ) {
318 - return true;
 319+ return false;
319320 }
320321 if( isset( $this->mParams['moveonly'] ) && $action != 'move' ) {
321 - return true;
 322+ return false;
322323 }
323324 if( isset( $this->mParams['newaccountonly'] ) && $action != 'new-account' ) {
324 - return true;
 325+ return false;
325326 }
326327 if( !isset( $this->mParams['noedit'] ) && $action == 'edit' ) {
327 - return true;
 328+ return false;
328329 }
329330 if ( isset( $this->mParams['reupload'] ) && $action == 'upload' ) {
330331 // Special:Upload also checks 'create' permissions when not reuploading
331 - return true;
 332+ return false;
332333 }
333 - return false;
 334+ return true;
334335 }
335 - return true;
 336+ return false;
336337 }
337338
338339 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r84602Invert match call for whitelist also...reedy16:30, 23 March 2011
r846051.17wmf1: MFT r84573, r84575, r84579, r84581, r84602 (upload / blacklist fixes)catrope17:00, 23 March 2011
r85033MFT more extension revs: r82601, r82654, r82698, r82755, r82756, r82759, r829...demon18:49, 30 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84573Followup r65898, fix inverse logic for title existence...reedy22:22, 22 March 2011
r84575Followup r76344, fix another inversed logic...reedy22:30, 22 March 2011
r84577* (bug 28166) UploadBase assumes that 'edit' and 'upload' rights are not per ...reedy22:36, 22 March 2011

Comments

#Comment by Catrope (talk | contribs)   16:17, 23 March 2011
+	 * @return TRUE if the the regex matches the title, and is not overridden
+	 * else if it doesn't match (or was overridden)

Did you mean s/else/false/ ?

Status & tagging log