MediaWiki  master
PatrolLog.php
Go to the documentation of this file.
1 <?php
29 class PatrolLog {
30 
42  public static function record( $rc, $auto, User $user, $tags = null ) {
43  // Do not log autopatrol actions: T184485
44  if ( $auto ) {
45  return false;
46  }
47 
48  if ( !$rc instanceof RecentChange ) {
49  $rc = RecentChange::newFromId( $rc );
50  if ( !is_object( $rc ) ) {
51  return false;
52  }
53  }
54 
55  $entry = new ManualLogEntry( 'patrol', 'patrol' );
56  $entry->setTarget( $rc->getTitle() );
57  $entry->setParameters( self::buildParams( $rc ) );
58  $entry->setPerformer( $user );
59  $entry->addTags( $tags );
60  $logid = $entry->insert();
61  $entry->publish( $logid, 'udp' );
62 
63  return true;
64  }
65 
72  private static function buildParams( $change ) {
73  return [
74  '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
75  '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
76  '6::auto' => 0
77  ];
78  }
79 }
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:72
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:56
PatrolLog\record
static record( $rc, $auto, User $user, $tags=null)
Record a log event for a change being patrolled.
Definition: PatrolLog.php:42