r112054 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112053‎ | r112054 | r112055 >
Date:22:27, 21 February 2012
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Added $performer parameter to PatrolLog::record() and pass it from WikiPage::doEdit() and RecentChange::doMarkPatrolled() since the performer is not necessarily $wgUser
Modified paths:
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/includes/WikiPage.php (modified) (history)
  • /trunk/phase3/includes/logging/PatrolLog.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/RecentChange.php
@@ -336,7 +336,7 @@
337337 // Actually set the 'patrolled' flag in RC
338338 $this->reallyMarkPatrolled();
339339 // Log this patrol event
340 - PatrolLog::record( $this, $auto );
 340+ PatrolLog::record( $this, $auto, $user );
341341 wfRunHooks( 'MarkPatrolledComplete', array($this->getAttribute('rc_id'), &$user, false) );
342342 return array();
343343 }
Index: trunk/phase3/includes/logging/PatrolLog.php
@@ -14,10 +14,11 @@
1515 *
1616 * @param $rc Mixed: change identifier or RecentChange object
1717 * @param $auto Boolean: was this patrol event automatic?
 18+ * @param $performer User: user performing the action or null to use $wgUser
1819 *
1920 * @return bool
2021 */
21 - public static function record( $rc, $auto = false ) {
 22+ public static function record( $rc, $auto = false, User $user = null ) {
2223 if ( !$rc instanceof RecentChange ) {
2324 $rc = RecentChange::newFromId( $rc );
2425 if ( !is_object( $rc ) ) {
@@ -27,12 +28,15 @@
2829
2930 $title = Title::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
3031 if( $title ) {
31 - global $wgUser;
 32+ if ( !$user ) {
 33+ global $wgUser;
 34+ $user = $wgUser;
 35+ }
3236
3337 $entry = new ManualLogEntry( 'patrol', 'patrol' );
3438 $entry->setTarget( $title );
3539 $entry->setParameters( self::buildParams( $rc, $auto ) );
36 - $entry->setPerformer( $wgUser );
 40+ $entry->setPerformer( $user );
3741 $logid = $entry->insert();
3842 if ( !$auto ) {
3943 $entry->publish( $logid, 'udp' );
Index: trunk/phase3/includes/WikiPage.php
@@ -1368,7 +1368,7 @@
13691369
13701370 # Log auto-patrolled edits
13711371 if ( $patrolled ) {
1372 - PatrolLog::record( $rc, true );
 1372+ PatrolLog::record( $rc, true, $user );
13731373 }
13741374 }
13751375 $user->incEditCount();
@@ -1449,7 +1449,7 @@
14501450
14511451 # Log auto-patrolled edits
14521452 if ( $patrolled ) {
1453 - PatrolLog::record( $rc, true );
 1453+ PatrolLog::record( $rc, true, $user );
14541454 }
14551455 }
14561456 $user->incEditCount();

Sign-offs

UserFlagDate
Nikerabbitinspected07:50, 22 February 2012

Comments

#Comment by Nikerabbit (talk | contribs)   07:50, 22 February 2012

Is this the only caller, or do we need the $wgUser default for other callers?

#Comment by IAlex (talk | contribs)   07:54, 22 February 2012

These are the only callers in core, but it remains one in extensions/InterwikiIntegration/InterwikiIntegrationRecentChange.php.

Status & tagging log