Allow to pass a rev id to a log entry without making it unpatrolled
authorcenarium <cenarium.sysop@gmail.com>
Tue, 23 Feb 2016 17:17:17 +0000 (18:17 +0100)
committercenarium <cenarium.sysop@gmail.com>
Mon, 14 Mar 2016 15:11:05 +0000 (16:11 +0100)
This adds new methods to ManualLogEntry that allow to specify that
a log entry is patrollable. RecentChange::newLogEntry then checks
this in order to allow or not unpatrolled status instead of checking
if there is an associated rev id. This allows to associate a revision
to a log entry without possibly making the recent change unpatrolled,
and extensions can implement patrol of actions not dependent on an
associated revision id.

Bug: T127848
Change-Id: I98298047142819b69639e6ca9d77c5ba982a380c

includes/changes/RecentChange.php
includes/filerepo/file/LocalFile.php
includes/logging/LogEntry.php

index b6a0868..f3bbb9e 100644 (file)
@@ -719,11 +719,12 @@ class RecentChange {
         * @param int $newId
         * @param string $actionCommentIRC
         * @param int $revId Id of associated revision, if any
+        * @param bool $isPatrollable Whether this log entry is patrollable
         * @return RecentChange
         */
        public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
                $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
-               $revId = 0 ) {
+               $revId = 0, $isPatrollable = false ) {
                global $wgRequest;
 
                # # Get pageStatus for email notification
@@ -747,9 +748,8 @@ class RecentChange {
                                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;
+               // Allow unpatrolled status for patrollable log entries
+               $markPatrolled = $isPatrollable ? $user->isAllowed( 'autopatrol' ) : true;
 
                $rc = new RecentChange;
                $rc->mTitle = $target;
index 0a3ded7..a324283 100644 (file)
@@ -1485,6 +1485,9 @@ class LocalFile extends File {
                                $logEntry->setTags( $tags );
                        }
 
+                       # Uploads can be patrolled
+                       $logEntry->setIsPatrollable( true );
+
                        # Now that the log entry is up-to-date, make an RC entry.
                        $logEntry->publish( $logId );
 
index 1d0a543..20d0217 100644 (file)
@@ -428,6 +428,9 @@ class ManualLogEntry extends LogEntryBase {
        /** @var int ID of the log entry */
        protected $id;
 
+       /** @var Can this log entry be patrolled? */
+       protected $isPatrollable = false;
+
        /** @var bool Whether this is a legacy log entry */
        protected $legacy = false;
 
@@ -545,6 +548,19 @@ class ManualLogEntry extends LogEntryBase {
                $this->tags = $tags;
        }
 
+       /**
+        * Set whether this log entry should be made patrollable
+        * This shouldn't depend on config, only on whether there is full support
+        * in the software for patrolling this log entry.
+        * False by default
+        *
+        * @since 1.27
+        * @param bool $patrollable
+        */
+       public function setIsPatrollable( $patrollable ) {
+               $this->isPatrollable = (bool)$patrollable;
+       }
+
        /**
         * Set the 'legacy' flag
         *
@@ -679,7 +695,8 @@ class ManualLogEntry extends LogEntryBase {
                        LogEntryBase::makeParamBlob( $this->getParameters() ),
                        $newId,
                        $formatter->getIRCActionComment(), // Used for IRC feeds
-                       $this->getAssociatedRevId() // Used for e.g. moves and uploads
+                       $this->getAssociatedRevId(), // Used for e.g. moves and uploads
+                       $this->getIsPatrollable()
                );
        }
 
@@ -706,8 +723,8 @@ class ManualLogEntry extends LogEntryBase {
                        $rc->notifyRCFeeds();
                }
 
-               // Log the autopatrol if an associated rev id was passed
-               if ( $this->getAssociatedRevId() > 0 &&
+               // Log the autopatrol if the log entry is patrollable
+               if ( $this->getIsPatrollable() &&
                        $rc->getAttribute( 'rc_patrolled' ) === 1 ) {
                        PatrolLog::record( $rc, true, $this->getPerformer() );
                }
@@ -775,6 +792,16 @@ class ManualLogEntry extends LogEntryBase {
                return $this->tags;
        }
 
+       /**
+        * Whether this log entry is patrollable
+        *
+        * @since 1.27
+        * @return bool
+        */
+       public function getIsPatrollable() {
+               return $this->isPatrollable;
+       }
+
        /**
         * @since 1.25
         * @return bool