r84605 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84604‎ | r84605 | r84606 >
Date:17:00, 23 March 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r84573, r84575, r84579, r84581, r84602 (upload / blacklist fixes)
Modified paths:
  • /branches/wmf/1.17wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php (modified) (history)
  • /branches/wmf/1.17wmf1/includes/upload/UploadBase.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/extensions/TitleBlacklist/TitleBlacklist.list.php
@@ -28,7 +28,6 @@
2929 //Try to find something in the cache
3030 $cachedBlacklist = $wgMemc->get( wfMemcKey( "title_blacklist_entries" ) );
3131 if( is_array( $cachedBlacklist ) && count( $cachedBlacklist ) > 0 && ( $cachedBlacklist[0]->getFormatVersion() == self::VERSION ) ) {
32 -
3332 $this->mBlacklist = $cachedBlacklist;
3433 wfProfileOut( __METHOD__ );
3534 return;
@@ -105,7 +104,7 @@
106105
107106 return '';
108107 }
109 -
 108+
110109 /**
111110 * Parse blacklist from a string
112111 *
@@ -116,8 +115,7 @@
117116 wfProfileIn( __METHOD__ );
118117 $lines = preg_split( "/\r?\n/", $list );
119118 $result = array();
120 - foreach ( $lines as $line )
121 - {
 119+ foreach ( $lines as $line ) {
122120 $line = TitleBlacklistEntry :: newFromString( $line );
123121 if ( $line ) {
124122 $result[] = $line;
@@ -147,7 +145,7 @@
148146 }
149147
150148 /**
151 - * Check whether the blacklist restricts
 149+ * Check whether the blacklist restricts
152150 * performing a specific action on the given Title
153151 *
154152 * @param $title Title to check
@@ -161,18 +159,18 @@
162160 }
163161 $blacklist = $this->getBlacklist();
164162 foreach ( $blacklist as $item ) {
165 - if( !$item->matches( $title, $action ) ) {
 163+ if( $item->matches( $title, $action ) ) {
166164 if( $this->isWhitelisted( $title, $action ) ) {
167165 return false;
168166 }
169 - return $item;
 167+ return $item; // "returning true"
170168 }
171169 }
172170 return false;
173171 }
174 -
 172+
175173 /**
176 - * Check whether it has been explicitly whitelisted that the
 174+ * Check whether it has been explicitly whitelisted that the
177175 * current User may perform a specific action on the given Title
178176 *
179177 * @param $title Title to check
@@ -186,13 +184,13 @@
187185 }
188186 $whitelist = $this->getWhitelist();
189187 foreach( $whitelist as $item ) {
190 - if( !$item->matches( $title, $action ) ) {
 188+ if( $item->matches( $title, $action ) ) {
191189 return true;
192190 }
193191 }
194192 return false;
195193 }
196 -
 194+
197195 /**
198196 * Get the current blacklist
199197 *
@@ -204,7 +202,7 @@
205203 }
206204 return $this->mBlacklist;
207205 }
208 -
 206+
209207 /*
210208 * Get the current whitelist
211209 *
@@ -216,7 +214,7 @@
217215 }
218216 return $this->mWhitelist;
219217 }
220 -
 218+
221219 /**
222220 * Get the text of a blacklist source via HTTP
223221 *
@@ -236,7 +234,7 @@
237235 }
238236 return $result;
239237 }
240 -
 238+
241239 /**
242240 * Invalidate the blacklist cache
243241 */
@@ -256,13 +254,14 @@
257255 foreach( $blacklist as $e ) {
258256 wfSuppressWarnings();
259257 $regex = $e->getRegex();
260 - if( preg_match( "/{$regex}/u", '' ) === false )
 258+ if( preg_match( "/{$regex}/u", '' ) === false ) {
261259 $badEntries[] = $e->getRaw();
 260+ }
262261 wfRestoreWarnings();
263262 }
264263 return $badEntries;
265264 }
266 -
 265+
267266 /**
268267 * Inidcates whether user can override blacklist on certain action.
269268 *
@@ -306,7 +305,8 @@
307306 *
308307 * @param $title Title to check
309308 * @param $action %Action to check
310 - * @return TRUE if the user can; otherwise FALSE
 309+ * @return TRUE if the the regex matches the title, and is not overridden
 310+ * else false if it doesn't match (or was overridden)
311311 */
312312 public function matches( $title, $action ) {
313313 global $wgUser;
@@ -315,24 +315,24 @@
316316 wfRestoreWarnings();
317317 if( $match ) {
318318 if( isset( $this->mParams['autoconfirmed'] ) && $wgUser->isAllowed( 'autoconfirmed' ) ) {
319 - return true;
 319+ return false;
320320 }
321321 if( isset( $this->mParams['moveonly'] ) && $action != 'move' ) {
322 - return true;
 322+ return false;
323323 }
324324 if( isset( $this->mParams['newaccountonly'] ) && $action != 'new-account' ) {
325 - return true;
 325+ return false;
326326 }
327327 if( !isset( $this->mParams['noedit'] ) && $action == 'edit' ) {
328 - return true;
 328+ return false;
329329 }
330330 if ( isset( $this->mParams['reupload'] ) && $action == 'upload' ) {
331331 // Special:Upload also checks 'create' permissions when not reuploading
332 - return true;
 332+ return false;
333333 }
334 - return false;
 334+ return true;
335335 }
336 - return true;
 336+ return false;
337337 }
338338
339339 /**
Index: branches/wmf/1.17wmf1/includes/upload/UploadBase.php
@@ -402,7 +402,7 @@
403403 }
404404 $permErrors = $nt->getUserPermissionsErrors( 'edit', $user );
405405 $permErrorsUpload = $nt->getUserPermissionsErrors( 'upload', $user );
406 - if ( $nt->exists() ) {
 406+ if ( !$nt->exists() ) {
407407 $permErrorsCreate = $nt->getUserPermissionsErrors( 'createpage', $user );
408408 } else {
409409 $permErrorsCreate = array();
Property changes on: branches/wmf/1.17wmf1/includes/upload/UploadBase.php
___________________________________________________________________
Modified: svn:mergeinfo
410410 Merged /trunk/phase3/includes/upload/UploadBase.php:r84573
Index: branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php
@@ -448,8 +448,8 @@
449449 $permErrors = $this->mUpload->verifyPermissions( $wgUser );
450450 if( $permErrors !== true ) {
451451 $code = array_shift( $permErrors[0] );
452 - $this->showRecoverableUploadError( wfMsgExt( $code[0],
453 - 'parseinline', $code[1] ) );
 452+ $this->showRecoverableUploadError( wfMsgExt( $code,
 453+ 'parseinline', $permErrors[0] ) );
454454 return;
455455 }
456456
Property changes on: branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php
___________________________________________________________________
Modified: svn:mergeinfo
457457 Merged /trunk/phase3/includes/specials/SpecialUpload.php:r84579

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
r84579Partial revert to r83979...reedy22:49, 22 March 2011
r84581Followup r84575, bug 27470...reedy23:07, 22 March 2011
r84602Invert match call for whitelist also...reedy16:30, 23 March 2011

Status & tagging log