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' ) );
30 $entry = new ManualLogEntry( 'patrol', 'patrol' );
31 $entry->setTarget( $title );
32 $entry->setParameters( self
::buildParams( $rc, $auto ) );
33 $entry->setPerformer( User
::newFromName( $rc->getAttribute( 'rc_user_text' ), false ) );
34 $logid = $entry->insert();
36 $entry->publish( $logid, 'udp' );
44 * Prepare log parameters for a patrolled change
46 * @param $change RecentChange to represent
47 * @param $auto Boolean: whether the patrol event was automatic
50 private static function buildParams( $change, $auto ) {
52 '4::curid' => $change->getAttribute( 'rc_this_oldid' ),
53 '5::previd' => $change->getAttribute( 'rc_last_oldid' ),
54 '6::auto' => (int)$auto