/**
* Record a log event for a change being patrolled
*
- * @param $rc Mixed: change identifier or RecentChange object
- * @param $auto Boolean: was this patrol event automatic?
- * @param $user User: user performing the action or null to use $wgUser
+ * @param int|RecentChange $rc Change identifier or RecentChange object
+ * @param bool $auto Was this patrol event automatic?
+ * @param User $user User performing the action or null to use $wgUser
+ * @param string|string[] $tags Change tags to add to the patrol log entry
+ * ($user should be able to add the specified tags before this is called)
*
* @return bool
*/
- public static function record( $rc, $auto = false, User $user = null ) {
+ public static function record( $rc, $auto = false, User $user = null, $tags = null ) {
global $wgLogAutopatrol;
// do not log autopatrolled edits if setting disables it
$user = $wgUser;
}
- $entry = new ManualLogEntry( 'patrol', 'patrol' );
+ $action = $auto ? 'autopatrol' : 'patrol';
+
+ $entry = new ManualLogEntry( 'patrol', $action );
$entry->setTarget( $rc->getTitle() );
$entry->setParameters( self::buildParams( $rc, $auto ) );
$entry->setPerformer( $user );
+ $entry->setTags( $tags );
$logid = $entry->insert();
if ( !$auto ) {
$entry->publish( $logid, 'udp' );
/**
* Prepare log parameters for a patrolled change
*
- * @param $change RecentChange to represent
- * @param $auto Boolean: whether the patrol event was automatic
- * @return Array
+ * @param RecentChange $change RecentChange to represent
+ * @param bool $auto Whether the patrol event was automatic
+ * @return array
*/
private static function buildParams( $change, $auto ) {
- return array(
+ return [
'4::curid' => $change->getAttribute( 'rc_this_oldid' ),
'5::previd' => $change->getAttribute( 'rc_last_oldid' ),
'6::auto' => (int)$auto
- );
+ ];
}
}