MediaWiki master
PatrolLog.php
Go to the documentation of this file.
1<?php
27
32class PatrolLog {
33
45 public static function record( $rc, $auto, UserIdentity $user, $tags = null ) {
46 // Do not log autopatrol actions: T184485
47 if ( $auto ) {
48 return false;
49 }
50
51 if ( !$rc instanceof RecentChange ) {
52 $rc = RecentChange::newFromId( $rc );
53 if ( !is_object( $rc ) ) {
54 return false;
55 }
56 }
57
58 $entry = new ManualLogEntry( 'patrol', 'patrol' );
59
60 // B/C: ->getPage() on RC will return a page reference or null, reconcile this in
61 // $entry->setTarget() call so we don't throw.
62 $page = $rc->getPage() ?? PageReferenceValue::localReference( NS_SPECIAL, 'Badtitle' );
63 $entry->setTarget( $page );
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}
const NS_SPECIAL
Definition Defines.php:54
Class for creating new log entries and inserting them into the database.
Immutable value object representing a page reference.
Class containing static functions for working with logs of patrol events.
Definition PatrolLog.php:32
static record( $rc, $auto, UserIdentity $user, $tags=null)
Record a log event for a change being patrolled.
Definition PatrolLog.php:45
Utility class for creating and reading rows in the recentchanges table.
Interface for objects representing user identity.