From d7a37e8daa8282ccd4e815e1bc0e2adf82a8d467 Mon Sep 17 00:00:00 2001 From: cenarium Date: Tue, 23 Feb 2016 18:17:17 +0100 Subject: [PATCH] Allow to pass a rev id to a log entry without making it unpatrolled 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 | 8 +++---- includes/filerepo/file/LocalFile.php | 3 +++ includes/logging/LogEntry.php | 33 +++++++++++++++++++++++++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index b6a086805e..f3bbb9e527 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -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; diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 0a3ded748f..a324283d5f 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -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 ); diff --git a/includes/logging/LogEntry.php b/includes/logging/LogEntry.php index 1d0a54361f..20d0217baa 100644 --- a/includes/logging/LogEntry.php +++ b/includes/logging/LogEntry.php @@ -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 -- 2.20.1