r41061 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41060‎ | r41061 | r41062 >
Date:07:55, 20 September 2008
Author:tstarling
Status:old
Tags:
Comment:
Fixed two patrol bugs:
* Return of ID instead of object from notifyNew() caused markPatrolled() to fail when the master and slave are different connections
* doMarkPatrolled() incorrectly checked for the patrol right instead of the autopatrol right when automatic patrol was requested.

Also fixed some formatting, more needed.
Modified paths:
  • /trunk/phase3/includes/RecentChange.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RecentChange.php
@@ -256,8 +256,9 @@
257257 $change = $change instanceof RecentChange
258258 ? $change
259259 : RecentChange::newFromId($change);
260 - if(!$change instanceof RecentChange)
 260+ if( !$change instanceof RecentChange ) {
261261 return null;
 262+ }
262263 return $change->doMarkPatrolled( $auto );
263264 }
264265
@@ -273,22 +274,34 @@
274275 $errors = array();
275276 // If recentchanges patrol is disabled, only new pages
276277 // can be patrolled
277 - if(!$wgUseRCPatrol && (!$wgUseNPPatrol || $this->getAttribute('rc_type') != RC_NEW))
 278+ if ( !$wgUseRCPatrol
 279+ && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) )
 280+ {
278281 $errors[] = array('rcpatroldisabled');
279 - $errors = array_merge($errors, $this->getTitle()->getUserPermissionsErrors('patrol', $wgUser));
 282+ }
 283+
 284+ // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
 285+ $right = $auto ? 'autopatrol' : 'patrol';
 286+ $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $wgUser ) );
280287 if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$wgUser, false)) )
281 - $errors[] = array('hookaborted');
 288+ $errors[] = array('hookaborted');
 289+
282290 // Users without the 'autopatrol' right can't patrol their
283291 // own revisions
284292 if( $wgUser->getName() == $this->getAttribute('rc_user_text') && !$wgUser->isAllowed('autopatrol') )
285293 $errors[] = array('markedaspatrollederror-noautopatrol');
286 - if( !empty($errors) )
 294+
 295+ if( $errors ) {
287296 return $errors;
 297+ }
 298+
288299 // If the change was patrolled already, do nothing
289300 if( $this->getAttribute('rc_patrolled') )
290301 return array();
 302+
291303 // Actually set the 'patrolled' flag in RC
292304 $this->reallyMarkPatrolled();
 305+
293306 // Log this patrol event
294307 PatrolLog::record( $this, $auto );
295308 wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$wgUser, false) );
@@ -415,7 +428,7 @@
416429 'newSize' => $size
417430 );
418431 $rc->save();
419 - return( $rc->mAttribs['rc_id'] );
 432+ return $rc;
420433 }
421434
422435 # Makes an entry in the database corresponding to a rename