* @return array Array of permissions errors, see Title::getUserPermissionsErrors()
*/
public function doMarkPatrolled( User $user, $auto = false ) {
- global $wgUseRCPatrol, $wgUseNPPatrol;
+ global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol;
$errors = array();
- // If recentchanges patrol is disabled, only new pages
- // can be patrolled
- if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) ) {
+ // If recentchanges patrol is disabled, only new pages or new file versions
+ // can be patrolled, provided the appropriate config variable is set
+ if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
+ ( !$wgUseFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
+ $this->getAttribute( 'rc_log_type' ) == 'upload' ) ) ) {
$errors[] = array( 'rcpatroldisabled' );
}
// Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
* @param int $newSize
* @param int $newId
* @param int $patrol
+ * @param array $tags
* @return RecentChange
*/
public static function notifyEdit(
$timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
- $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0
+ $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
+ $tags = array()
) {
$rc = new RecentChange;
$rc->mTitle = $title;
'pageStatus' => 'changed'
);
- DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
+ DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
+ if ( count( $tags ) ) {
+ ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
+ $rc->mAttribs['rc_this_oldid'], null, null );
+ }
} );
return $rc;
* @param int $size
* @param int $newId
* @param int $patrol
+ * @param array $tags
* @return RecentChange
*/
public static function notifyNew(
$timestamp, &$title, $minor, &$user, $comment, $bot,
- $ip = '', $size = 0, $newId = 0, $patrol = 0
+ $ip = '', $size = 0, $newId = 0, $patrol = 0, $tags = array()
) {
$rc = new RecentChange;
$rc->mTitle = $title;
'pageStatus' => 'created'
);
- DeferredUpdates::addCallableUpdate( function() use ( $rc ) {
+ DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
$rc->save();
if ( $rc->mAttribs['rc_patrolled'] ) {
PatrolLog::record( $rc, true, $rc->getPerformer() );
}
+ if ( count( $tags ) ) {
+ ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
+ $rc->mAttribs['rc_this_oldid'], null, null );
+ }
} );
return $rc;
* @param string $params
* @param int $newId
* @param string $actionCommentIRC
+ * @param int $revId Id of associated revision, if any
* @return RecentChange
*/
public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
- $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '' ) {
+ $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
+ $revId = 0 ) {
global $wgRequest;
# # Get pageStatus for email notification
break;
}
+ // Allow unpatrolled status when an associated rev id is passed
+ // May be used in core by moves and uploads
+ $markPatrolled = ( $revId > 0 ) ? $user->isAllowed( 'autopatrol' ) : true;
+
$rc = new RecentChange;
$rc->mTitle = $target;
$rc->mPerformer = $user;
'rc_user' => $user->getId(),
'rc_user_text' => $user->getName(),
'rc_comment' => $logComment,
- 'rc_this_oldid' => 0,
+ 'rc_this_oldid' => $revId,
'rc_last_oldid' => 0,
'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
'rc_ip' => self::checkIPAddress( $ip ),
- 'rc_patrolled' => 1,
+ 'rc_patrolled' => $markPatrolled ? 1 : 0,
'rc_new' => 0, # obsolete
'rc_old_len' => null,
'rc_new_len' => null,
return $unserializedParams;
}
}
-