Fixed two patrol bugs:
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 20 Sep 2008 07:55:14 +0000 (07:55 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 20 Sep 2008 07:55:14 +0000 (07:55 +0000)
* 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.

includes/RecentChange.php

index c0b02dc..2fa4182 100644 (file)
@@ -256,8 +256,9 @@ class RecentChange
                $change = $change instanceof RecentChange
                        ? $change
                        : RecentChange::newFromId($change);
-               if(!$change instanceof RecentChange)
+               if( !$change instanceof RecentChange ) {
                        return null;
+               }
                return $change->doMarkPatrolled( $auto );
        }
        
@@ -273,22 +274,34 @@ class RecentChange
                $errors = array();
                // If recentchanges patrol is disabled, only new pages
                // can be patrolled
-               if(!$wgUseRCPatrol && (!$wgUseNPPatrol || $this->getAttribute('rc_type') != RC_NEW))
+               if ( !$wgUseRCPatrol 
+                       && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) ) 
+               {
                        $errors[] = array('rcpatroldisabled');
-               $errors = array_merge($errors, $this->getTitle()->getUserPermissionsErrors('patrol', $wgUser));
+               }
+
+               // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
+               $right = $auto ? 'autopatrol' : 'patrol';
+               $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $wgUser ) );
                if( !wfRunHooks('MarkPatrolled', array($this->getAttribute('rc_id'), &$wgUser, false)) )
-                       $errors[] = array('hookaborted');               
+                       $errors[] = array('hookaborted');
+
                // Users without the 'autopatrol' right can't patrol their
                // own revisions
                if( $wgUser->getName() == $this->getAttribute('rc_user_text') && !$wgUser->isAllowed('autopatrol') )
                        $errors[] = array('markedaspatrollederror-noautopatrol');
-               if( !empty($errors) )
+
+               if( $errors ) {
                        return $errors;
+               }
+
                // If the change was patrolled already, do nothing
                if( $this->getAttribute('rc_patrolled') )
                        return array();
+
                // Actually set the 'patrolled' flag in RC
                $this->reallyMarkPatrolled();
+
                // Log this patrol event
                PatrolLog::record( $this, $auto );
                wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$wgUser, false) );
@@ -415,7 +428,7 @@ class RecentChange
                        'newSize' => $size
                );
                $rc->save();
-               return( $rc->mAttribs['rc_id'] );
+               return $rc;     
        }
 
        # Makes an entry in the database corresponding to a rename