Merge "Move section ID fallbacks into headers themselves"
[lhc/web/wiklou.git] / includes / specials / SpecialImport.php
index ce88624..beb454d 100644 (file)
@@ -46,9 +46,6 @@ class SpecialImport extends SpecialPage {
        private $pageLinkDepth;
        private $importSources;
 
-       /**
-        * Constructor
-        */
        public function __construct() {
                parent::__construct( 'Import', 'import' );
        }
@@ -176,10 +173,8 @@ class SpecialImport extends SpecialPage {
 
                $out = $this->getOutput();
                if ( !$source->isGood() ) {
-                       $out->wrapWikiMsg(
-                               "<p class=\"error\">\n$1\n</p>",
-                               [ 'importfailed', $source->getWikiText() ]
-                       );
+                       $out->addWikiText( "<p class=\"error\">\n" .
+                               $this->msg( 'importfailed', $source->getWikiText() )->parse() . "\n</p>" );
                } else {
                        $importer = new WikiImporter( $source->value, $this->getConfig() );
                        if ( !is_null( $this->namespace ) ) {
@@ -536,6 +531,7 @@ class SpecialImport extends SpecialPage {
  */
 class ImportReporter extends ContextSource {
        private $reason = false;
+       private $logTags = [];
        private $mOriginalLogCallback = null;
        private $mOriginalPageOutCallback = null;
        private $mLogItemCount = 0;
@@ -558,6 +554,16 @@ class ImportReporter extends ContextSource {
                $this->reason = $reason;
        }
 
+       /**
+        * Sets change tags to apply to the import log entry and null revision.
+        *
+        * @param array $tags
+        * @since 1.29
+        */
+       public function setChangeTags( array $tags ) {
+               $this->logTags = $tags;
+       }
+
        function open() {
                $this->getOutput()->addHTML( "<ul>\n" );
        }
@@ -628,14 +634,6 @@ class ImportReporter extends ContextSource {
                                        . $this->reason;
                        }
 
-                       $logEntry = new ManualLogEntry( 'import', $action );
-                       $logEntry->setTarget( $title );
-                       $logEntry->setComment( $this->reason );
-                       $logEntry->setPerformer( $this->getUser() );
-                       $logEntry->setParameters( $logParams );
-                       $logid = $logEntry->insert();
-                       $logEntry->publish( $logid );
-
                        $comment = $detail; // quick
                        $dbw = wfGetDB( DB_MASTER );
                        $latest = $title->getLatestRevID();
@@ -647,8 +645,9 @@ class ImportReporter extends ContextSource {
                                $this->getUser()
                        );
 
+                       $nullRevId = null;
                        if ( !is_null( $nullRevision ) ) {
-                               $nullRevision->insertOn( $dbw );
+                               $nullRevId = $nullRevision->insertOn( $dbw );
                                $page = WikiPage::factory( $title );
                                # Update page record
                                $page->updateRevisionOn( $dbw, $nullRevision );
@@ -657,6 +656,22 @@ class ImportReporter extends ContextSource {
                                        [ $page, $nullRevision, $latest, $this->getUser() ]
                                );
                        }
+
+                       // Create the import log entry
+                       $logEntry = new ManualLogEntry( 'import', $action );
+                       $logEntry->setTarget( $title );
+                       $logEntry->setComment( $this->reason );
+                       $logEntry->setPerformer( $this->getUser() );
+                       $logEntry->setParameters( $logParams );
+                       $logid = $logEntry->insert();
+                       if ( count( $this->logTags ) ) {
+                               $logEntry->setTags( $this->logTags );
+                       }
+                       // Make sure the null revision will be tagged as well
+                       $logEntry->setAssociatedRevId( $nullRevId );
+
+                       $logEntry->publish( $logid );
+
                } else {
                        $this->getOutput()->addHTML( "<li>" . $linkRenderer->makeKnownLink( $title ) . " " .
                                $this->msg( 'import-nonewrevisions' )->escaped() . "</li>\n" );