MediaWiki  master
PatrolLog.php
Go to the documentation of this file.
1 <?php
29 class PatrolLog {
30 
43  public static function record( $rc, $auto = false, User $user = null, $tags = null ) {
44  // Do not log autopatrol actions: T184485
45  if ( $auto ) {
46  return false;
47  }
48 
49  if ( !$rc instanceof RecentChange ) {
50  $rc = RecentChange::newFromId( $rc );
51  if ( !is_object( $rc ) ) {
52  return false;
53  }
54  }
55 
56  if ( !$user ) {
57  wfDeprecated( __METHOD__ . ' without passing a $user parameter', '1.35' );
58  global $wgUser;
59  $user = $wgUser;
60  }
61 
62  $entry = new ManualLogEntry( 'patrol', 'patrol' );
63  $entry->setTarget( $rc->getTitle() );
64  $entry->setParameters( self::buildParams( $rc ) );
65  $entry->setPerformer( $user );
66  $entry->addTags( $tags );
67  $logid = $entry->insert();
68  $entry->publish( $logid, 'udp' );
69 
70  return true;
71  }
72 
79  private static function buildParams( $change ) {
80  return [
81  '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
82  '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
83  '6::auto' => 0
84  ];
85  }
86 }
PatrolLog\record
static record( $rc, $auto=false, User $user=null, $tags=null)
Record a log event for a change being patrolled.
Definition: PatrolLog.php:43
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:73
PatrolLog\buildParams
static buildParams( $change)
Prepare log parameters for a patrolled change.
Definition: PatrolLog.php:79
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1026
RecentChange\newFromId
static newFromId( $rcid)
Obtain the recent change with a given rc_id value.
Definition: RecentChange.php:207
PatrolLog
Class containing static functions for working with logs of patrol events.
Definition: PatrolLog.php:29
ManualLogEntry
Class for creating new log entries and inserting them into the database.
Definition: ManualLogEntry.php:42
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:55