Merge "Add IContextSource as parameter to ChangeTags::formatSummaryRow"
[lhc/web/wiklou.git] / includes / changes / RecentChange.php
index 61c7000..c33a94b 100644 (file)
@@ -456,11 +456,13 @@ class RecentChange {
         * @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"
@@ -536,11 +538,13 @@ class RecentChange {
         * @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;
@@ -579,11 +583,15 @@ class RecentChange {
                        '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;
@@ -603,11 +611,12 @@ class RecentChange {
         * @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;
@@ -646,11 +655,15 @@ class RecentChange {
                        '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;