Migrate import log to new log system
authorumherirrender <umherirrender_de.wp@web.de>
Mon, 4 Aug 2014 19:35:18 +0000 (21:35 +0200)
committerNikerabbit <niklas.laxstrom@gmail.com>
Wed, 18 Mar 2015 13:21:52 +0000 (13:21 +0000)
There is no need for an extra formatter class, because at the moment
there is nothing extra to format.

This allows use of gender on Special:Log. Old messages are kept for use
in IRC. A test was added to ensure an unchanged IRC message.

The new log message for import-interwiki is used from
I3ca8b21bce49b41cac7109efb8056ca4469b88d7 to avoid "transwiki jargon".

Bug: T57404
Change-Id: I590075b203548c071a98c1eaa4b1bc9250f60e22

includes/DefaultSettings.php
includes/logging/LogFormatter.php
includes/specials/SpecialImport.php
languages/i18n/en.json
languages/i18n/qqq.json
tests/phpunit/includes/changes/RecentChangeTest.php

index 8a4769d..80af4ae 100644 (file)
@@ -6689,8 +6689,6 @@ $wgLogActions = array(
        'protect/modify' => 'modifiedarticleprotection',
        'protect/unprotect' => 'unprotectedarticle',
        'protect/move_prot' => 'movedarticleprotection',
-       'import/upload' => 'import-logentry-upload',
-       'import/interwiki' => 'import-logentry-interwiki',
 );
 
 /**
@@ -6725,6 +6723,8 @@ $wgLogActionsHandlers = array(
        'block/reblock' => 'BlockLogFormatter',
        'suppress/block' => 'BlockLogFormatter',
        'suppress/reblock' => 'BlockLogFormatter',
+       'import/upload' => 'LogFormatter',
+       'import/interwiki' => 'LogFormatter',
 );
 
 /**
index ce6e0ad..267a319 100644 (file)
@@ -363,6 +363,19 @@ class LogFormatter {
                                                break;
                                }
                                break;
+
+                       case 'import':
+                               switch ( $entry->getSubtype() ) {
+                                       case 'upload':
+                                               $text = wfMessage( 'import-logentry-upload' )
+                                                       ->rawParams( $target )->inContentLanguage()->escaped();
+                                               break;
+                                       case 'interwiki':
+                                               $text = wfMessage( 'import-logentry-interwiki' )
+                                                       ->rawParams( $target )->inContentLanguage()->escaped();
+                                               break;
+                               }
+                               break;
                        // case 'suppress' --private log -- aaron  (so we know who to blame in a few years :-D)
                        // default:
                }
index aa9b0f4..af86964 100644 (file)
@@ -546,7 +546,6 @@ class ImportReporter extends ContextSource {
                                        "</li>\n"
                        );
 
-                       $log = new LogPage( 'import' );
                        if ( $this->mIsUpload ) {
                                $detail = $this->msg( 'import-logentry-upload-detail' )->numParams(
                                        $successCount )->inContentLanguage()->text();
@@ -554,7 +553,7 @@ class ImportReporter extends ContextSource {
                                        $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
                                                . $this->reason;
                                }
-                               $log->addEntry( 'upload', $title, $detail, array(), $this->getUser() );
+                               $action = 'upload';
                        } else {
                                $interwiki = '[[:' . $this->mInterwiki . ':' .
                                        $foreignTitle->getFullText() . ']]';
@@ -564,9 +563,16 @@ class ImportReporter extends ContextSource {
                                        $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
                                                . $this->reason;
                                }
-                               $log->addEntry( 'interwiki', $title, $detail, array(), $this->getUser() );
+                               $action = 'interwiki';
                        }
 
+                       $logEntry = new ManualLogEntry( 'import', $action );
+                       $logEntry->setTarget( $title );
+                       $logEntry->setComment( $detail );
+                       $logEntry->setPerformer( $this->getUser() );
+                       $logid = $logEntry->insert();
+                       $logEntry->publish( $logid );
+
                        $comment = $detail; // quick
                        $dbw = wfGetDB( DB_MASTER );
                        $latest = $title->getLatestRevID();
index a81a89e..b40dadb 100644 (file)
        "logentry-block-reblock": "$1 {{GENDER:$2|changed}} block settings for {{GENDER:$4|$3}} with an expiry time of $5 $6",
        "logentry-suppress-block": "$1 {{GENDER:$2|blocked}} {{GENDER:$4|$3}} with an expiry time of $5 $6",
        "logentry-suppress-reblock": "$1 {{GENDER:$2|changed}} block settings for {{GENDER:$4|$3}} with an expiry time of $5 $6",
+       "logentry-import-upload": "$1 {{GENDER:$2|imported}} $3 by file upload",
+       "logentry-import-interwiki": "$1 {{GENDER:$2|imported}} $3 from another wiki",
        "logentry-merge-merge": "$1 {{GENDER:$2|merged}} $3 into $4 (revisions up to $5)",
        "logentry-move-move": "$1 {{GENDER:$2|moved}} page $3 to $4",
        "logentry-move-move-noredirect": "$1 {{GENDER:$2|moved}} page $3 to $4 without leaving a redirect",
index 1761b18..6ac333c 100644 (file)
        "import-rootpage-nosubpage": "Used on [[Special:Import]], when the import namespace does not support subpages. Parameters:\n* $1 is a namespace name.",
        "importlogpage": "{{doc-logpage}}",
        "importlogpagetext": "This text appears at the top of the [{{canonicalurl:Special:Log|type=import}} import log] special page.",
-       "import-logentry-upload": "This is the text of an entry in the Import log (and Recent Changes), after hour (and date, only in the Import log) and sysop name:\n* $1 is the name of the imported file",
+       "import-logentry-upload": "{{ignored}}This is ''logentry'' message only used on IRC.\n* $1 is the name of the imported file",
        "import-logentry-upload-detail": "Used as success message and log entry. Parameters:\n* $1 - number of succeeded revisions\nSee also:\n* {{msg-mw|Import-logentry-interwiki-detail}}",
-       "import-logentry-interwiki": "Used as action listed in the log. Parameters:\n* $1 - page title",
+       "import-logentry-interwiki": "{{ignored}}This is ''logentry'' message only used on IRC. Parameters:\n* $1 - page title",
        "import-logentry-interwiki-detail": "Used as success message and log entry. Parameters:\n* $1 - number of succeeded revisions\n* $2 - interwiki name\nSee also:\n* {{msg-mw|Import-logentry-upload-detail}}",
        "javascripttest": "Title of the special page [[Special:JavaScriptTest]].\n\nSee also:\n* {{msg-mw|Javascripttest|title}}\n* {{msg-mw|Javascripttest-pagetext-noframework|summary}}\n* {{msg-mw|Javascripttest-pagetext-unknownframework|error message}}",
        "javascripttest-backlink": "{{optional}}\nUsed as subtitle in [[Special:JavaScriptTest]]. Parameters:\n* $1 - page title",
        "logentry-block-reblock": "{{Logentry|[[Special:Log/block]]}}\n* $4 - user name for gender or empty string for autoblocks\n* $5 - the block duration, localized and formatted with the english tooltip\n* $6 - block detail flags or empty string\n\nCf. {{msg-mw|Reblock-logentry}}",
        "logentry-suppress-block": "{{Logentry}}\n* $4 - user name for gender or empty string for autoblocks\n* $5 - the block duration, localized and formatted with the english tooltip\n* $6 - block detail flags or empty string",
        "logentry-suppress-reblock": "{{Logentry}}\n* $4 - user name for gender or empty string for autoblocks\n* $5 - the block duration, localized and formatted with the english tooltip\n* $6 - block detail flags or empty string",
+       "logentry-import-upload": "{{Logentry|[[Special:Log/import]]}}",
+       "logentry-import-interwiki": "{{Logentry|[[Special:Log/import]]}}",
        "logentry-merge-merge": "{{Logentry|[[Special:Log/merge]]}}\n* $4 - the page into which the content is merged\n* $5 - a timestamp of limit\n\nThe log and its associated special page 'MergeHistory' is not enabled by default.\n\nPlease note that the parameters in a log entry will appear in the log only in the default language of the wiki. View [[Special:Log]] for examples on translatewiki.net with English default language.",
        "logentry-move-move": "{{Logentry|[[Special:Log/move]]}}\nParameter $4, the target page, is also not visible to parser functions.",
        "logentry-move-move-noredirect": "{{Logentry|[[Special:Log/move]]}}\nParameter $4, the target page, is also not visible to parser functions.",
index e00a45a..b3cb7b5 100644 (file)
@@ -48,6 +48,8 @@ class RecentChangeTest extends MediaWikiTestCase {
         * - protect/unprotect
         * - upload/upload
         * - merge/merge
+        * - import/upload
+        * - import/interwiki
         *
         * As well as the following Auto Edit Summaries:
         * - blank
@@ -265,6 +267,29 @@ class RecentChangeTest extends MediaWikiTestCase {
                );
        }
 
+       /**
+        * @covers LogFormatter::getIRCActionText
+        */
+       public function testIrcMsgForLogTypeImport() {
+               $sep = $this->context->msg( 'colon-separator' )->text();
+
+               # import/upload
+               $this->assertIRCComment(
+                       $this->context->msg( 'import-logentry-upload', 'SomeTitle' )->plain() . $sep . $this->user_comment,
+                       'import', 'upload',
+                       array(),
+                       $this->user_comment
+               );
+
+               # import/interwiki
+               $this->assertIRCComment(
+                       $this->context->msg( 'import-logentry-interwiki', 'SomeTitle' )->plain() . $sep . $this->user_comment,
+                       'import', 'interwiki',
+                       array(),
+                       $this->user_comment
+               );
+       }
+
        /**
         * @todo Emulate these edits somehow and extract
         * raw edit summary from RecentChange object