Merge "Add separate log action for file reverts"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 2 Mar 2019 23:48:48 +0000 (23:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 2 Mar 2019 23:48:48 +0000 (23:48 +0000)
includes/DefaultSettings.php
includes/actions/RevertAction.php
includes/filerepo/file/LocalFile.php
includes/logging/LogFormatter.php
languages/i18n/en.json
languages/i18n/qqq.json
tests/phpunit/includes/logging/UploadLogFormatterTest.php

index 6259208..073e539 100644 (file)
@@ -7933,6 +7933,7 @@ $wgActionFilteredLogs = [
        'upload' => [
                'upload' => [ 'upload' ],
                'overwrite' => [ 'overwrite' ],
+               'revert' => [ 'revert' ],
        ],
 ];
 
index 68a0325..8a5d7c9 100644 (file)
@@ -136,7 +136,10 @@ class RevertAction extends FormAction {
                        0,
                        false,
                        false,
-                       $this->getUser()
+                       $this->getUser(),
+                       [],
+                       true,
+                       true
                );
        }
 
index 789d7c5..a3d1624 100644 (file)
@@ -1303,12 +1303,13 @@ class LocalFile extends File {
         *   (This doesn't check $user's permissions.)
         * @param bool $createNullRevision Set to false to avoid creation of a null revision on file
         *   upload, see T193621
+        * @param bool $revert If this file upload is a revert
         * @return Status On success, the value member contains the
         *     archive name, or an empty string if it was a new file.
         */
        function upload( $src, $comment, $pageText, $flags = 0, $props = false,
                $timestamp = false, $user = null, $tags = [],
-               $createNullRevision = true
+               $createNullRevision = true, $revert = false
        ) {
                if ( $this->getRepo()->getReadOnlyReason() !== false ) {
                        return $this->readOnlyFatalStatus();
@@ -1366,7 +1367,8 @@ class LocalFile extends File {
                                $timestamp,
                                $user,
                                $tags,
-                               $createNullRevision
+                               $createNullRevision,
+                               $revert
                        );
                        if ( !$uploadStatus->isOK() ) {
                                if ( $uploadStatus->hasMessage( 'filenotfound' ) ) {
@@ -1425,11 +1427,12 @@ class LocalFile extends File {
         * @param string[] $tags
         * @param bool $createNullRevision Set to false to avoid creation of a null revision on file
         *   upload, see T193621
+        * @param bool $revert If this file upload is a revert
         * @return Status
         */
        function recordUpload2(
                $oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null, $tags = [],
-               $createNullRevision = true
+               $createNullRevision = true, $revert = false
        ) {
                global $wgActorTableSchemaMigrationStage;
 
@@ -1602,8 +1605,16 @@ class LocalFile extends File {
                $wikiPage = new WikiFilePage( $descTitle );
                $wikiPage->setFile( $this );
 
+               // Determine log action. If reupload is done by reverting, use a special log_action.
+               if ( $revert === true ) {
+                       $logAction = 'revert';
+               } elseif ( $reupload === true ) {
+                       $logAction = 'overwrite';
+               } else {
+                       $logAction = 'upload';
+               }
                // Add the log entry...
-               $logEntry = new ManualLogEntry( 'upload', $reupload ? 'overwrite' : 'upload' );
+               $logEntry = new ManualLogEntry( 'upload', $logAction );
                $logEntry->setTimestamp( $this->timestamp );
                $logEntry->setPerformer( $user );
                $logEntry->setComment( $comment );
index b07f20e..6d45ed5 100644 (file)
@@ -329,6 +329,7 @@ class LogFormatter {
                                                        ->rawParams( $target )->inContentLanguage()->escaped();
                                                break;
                                        case 'overwrite':
+                                       case 'revert':
                                                $text = wfMessage( 'overwroteimage' )
                                                        ->rawParams( $target )->inContentLanguage()->escaped();
                                                break;
index bf2f19e..8700cec 100644 (file)
        "logentry-rights-autopromote": "$1 was automatically {{GENDER:$2|promoted}} from $4 to $5",
        "logentry-upload-upload": "$1 {{GENDER:$2|uploaded}} $3",
        "logentry-upload-overwrite": "$1 {{GENDER:$2|uploaded}} a new version of $3",
-       "logentry-upload-revert": "$1 {{GENDER:$2|uploaded}} $3",
+       "logentry-upload-revert": "$1 {{GENDER:$2|reverted}} $3 to an old version",
        "log-name-managetags": "Tag management log",
        "log-description-managetags": "This page lists management tasks related to [[Special:Tags|tags]]. The log contains only actions carried out manually by an administrator; tags may be created or deleted by the wiki software without an entry being recorded in this log.",
        "logentry-managetags-create": "$1 {{GENDER:$2|created}} the tag \"$4\"",
        "log-action-filter-suppress-reblock": "User suppression by reblock",
        "log-action-filter-upload-upload": "New upload",
        "log-action-filter-upload-overwrite": "Reupload",
+       "log-action-filter-upload-revert": "Revert",
        "authmanager-authn-not-in-progress": "Authentication is not in progress or session data has been lost. Please start again from the beginning.",
        "authmanager-authn-no-primary": "The supplied credentials could not be authenticated.",
        "authmanager-authn-no-local-user": "The supplied credentials are not associated with any user on this wiki.",
index 63a112c..fab3ddc 100644 (file)
        "log-action-filter-suppress-reblock": "{{doc-log-action-filter-action|suppress|reblock}}",
        "log-action-filter-upload-upload": "{{doc-log-action-filter-action|upload|upload}}",
        "log-action-filter-upload-overwrite": "{{doc-log-action-filter-action|upload|overwrite}}",
+       "log-action-filter-upload-revert": "{{doc-log-action-filter-action|upload|revert}}",
        "authmanager-authn-not-in-progress": "Error message when AuthManager session data is lost during authentication, or the user hits the \"continue\" endpoint without an active authentication attempt.",
        "authmanager-authn-no-primary": "Error message when no AuthenticationProvider handles the AuthenticationRequests for login. This might mean the user needs to fill out all the form fields.",
        "authmanager-authn-no-local-user": "Error message when authentication somehow succeeds without a username being known. This probably should never happen.",
index 2b4067f..b393949 100644 (file)
@@ -134,7 +134,7 @@ class UploadLogFormatterTest extends LogFormatterTestCase {
                                        ],
                                ],
                                [
-                                       'text' => 'User uploaded File:File.png',
+                                       'text' => 'User reverted File:File.png to an old version',
                                        'api' => [
                                                'img_sha1' => 'hash',
                                                'img_timestamp' => '2015-01-01T00:00:00Z',
@@ -153,7 +153,7 @@ class UploadLogFormatterTest extends LogFormatterTestCase {
                                        'params' => [],
                                ],
                                [
-                                       'text' => 'User uploaded File:File.png',
+                                       'text' => 'User reverted File:File.png to an old version',
                                        'api' => [],
                                ],
                        ],