4 * Class containing static functions for working with
5 * logs of patrol events
7 * @author Rob Church <robchur@gmail.com>
8 * @author Niklas Laxström
13 * Record a log event for a change being patrolled
15 * @param $rc Mixed: change identifier or RecentChange object
16 * @param $auto Boolean: was this patrol event automatic?
20 public static function record( $rc, $auto = false ) {
21 if ( !$rc instanceof RecentChange
) {
22 $rc = RecentChange
::newFromId( $rc );
23 if ( !is_object( $rc ) ) {
28 $title = Title
::makeTitleSafe( $rc->getAttribute( 'rc_namespace' ), $rc->getAttribute( 'rc_title' ) );
32 $entry = new ManualLogEntry( 'patrol', 'patrol' );
33 $entry->setTarget( $title );
34 $entry->setParameters( self
::buildParams( $rc, $auto ) );
35 $entry->setPerformer( $wgUser );
36 $logid = $entry->insert();
38 $entry->publish( $logid, 'udp' );
46 * Prepare log parameters for a patrolled change
48 * @param $change RecentChange to represent
49 * @param $auto Boolean: whether the patrol event was automatic
52 private static function buildParams( $change, $auto ) {
54 '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
55 '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
56 '6::auto' => (int)$auto