Added $performer parameter to PatrolLog::record() and pass it from WikiPage::doEdit...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 21 Feb 2012 22:27:33 +0000 (22:27 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 21 Feb 2012 22:27:33 +0000 (22:27 +0000)
includes/RecentChange.php
includes/WikiPage.php
includes/logging/PatrolLog.php

index b4531d8..67bc530 100644 (file)
@@ -336,7 +336,7 @@ class RecentChange {
                // Actually set the 'patrolled' flag in RC
                $this->reallyMarkPatrolled();
                // Log this patrol event
-               PatrolLog::record( $this, $auto );
+               PatrolLog::record( $this, $auto, $user );
                wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$user, false) );
                return array();
        }
index 99e33f6..daa7bbc 100644 (file)
@@ -1368,7 +1368,7 @@ class WikiPage extends Page {
 
                                                # Log auto-patrolled edits
                                                if ( $patrolled ) {
-                                                       PatrolLog::record( $rc, true );
+                                                       PatrolLog::record( $rc, true, $user );
                                                }
                                        }
                                        $user->incEditCount();
@@ -1449,7 +1449,7 @@ class WikiPage extends Page {
 
                                # Log auto-patrolled edits
                                if ( $patrolled ) {
-                                       PatrolLog::record( $rc, true );
+                                       PatrolLog::record( $rc, true, $user );
                                }
                        }
                        $user->incEditCount();
index eea348e..65c523d 100644 (file)
@@ -14,10 +14,11 @@ class PatrolLog {
         *
         * @param $rc Mixed: change identifier or RecentChange object
         * @param $auto Boolean: was this patrol event automatic?
+        * @param $performer User: user performing the action or null to use $wgUser
         *
         * @return bool
         */
-       public static function record( $rc, $auto = false ) {
+       public static function record( $rc, $auto = false, User $user = null ) {
                if ( !$rc instanceof RecentChange ) {
                        $rc = RecentChange::newFromId( $rc );
                        if ( !is_object( $rc ) ) {
@@ -27,12 +28,15 @@ class PatrolLog {
 
                $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
                if( $title ) {
-                       global $wgUser;
+                       if ( !$user ) {
+                               global $wgUser;
+                               $user = $wgUser;
+                       }
 
                        $entry = new ManualLogEntry( 'patrol', 'patrol' );
                        $entry->setTarget( $title );
                        $entry->setParameters( self::buildParams( $rc, $auto ) );
-                       $entry->setPerformer( $wgUser );
+                       $entry->setPerformer( $user );
                        $logid = $entry->insert();
                        if ( !$auto ) {
                                $entry->publish( $logid, 'udp' );