Preserve log comment text field value across import attempts
authorThis, that and the other <at.light@live.com.au>
Sun, 27 Jul 2014 11:02:59 +0000 (21:02 +1000)
committerUmherirrender <umherirrender_de.wp@web.de>
Wed, 1 Oct 2014 18:35:44 +0000 (18:35 +0000)
This was first attempted way back in r45340, but was reverted in r45489.

Bug: 16793
Change-Id: Ieb9fb7e7e918b2e7e2b8289b3fdf82a49ea75a17

includes/specials/SpecialImport.php

index eab4784..3d762aa 100644 (file)
@@ -30,6 +30,7 @@
  * @ingroup SpecialPage
  */
 class SpecialImport extends SpecialPage {
+       private $sourceName = false;
        private $interwiki = false;
        private $subproject;
        private $fullInterwikiPrefix;
@@ -98,7 +99,7 @@ class SpecialImport extends SpecialPage {
                $isUpload = false;
                $request = $this->getRequest();
                $this->namespace = $request->getIntOrNull( 'namespace' );
-               $sourceName = $request->getVal( "source" );
+               $this->sourceName = $request->getVal( "source" );
 
                $this->logcomment = $request->getText( 'log-comment' );
                $this->pageLinkDepth = $this->getConfig()->get( 'ExportMaxLinkDepth' ) == 0
@@ -109,14 +110,14 @@ class SpecialImport extends SpecialPage {
                $user = $this->getUser();
                if ( !$user->matchEditToken( $request->getVal( 'editToken' ) ) ) {
                        $source = Status::newFatal( 'import-token-mismatch' );
-               } elseif ( $sourceName == 'upload' ) {
+               } elseif ( $this->sourceName == 'upload' ) {
                        $isUpload = true;
                        if ( $user->isAllowed( 'importupload' ) ) {
                                $source = ImportStreamSource::newFromUpload( "xmlimport" );
                        } else {
                                throw new PermissionsError( 'importupload' );
                        }
-               } elseif ( $sourceName == "interwiki" ) {
+               } elseif ( $this->sourceName == "interwiki" ) {
                        if ( !$user->isAllowed( 'import' ) ) {
                                throw new PermissionsError( 'import' );
                        }
@@ -250,7 +251,8 @@ class SpecialImport extends SpecialPage {
                                        Xml::label( $this->msg( 'import-comment' )->text(), 'mw-import-comment' ) .
                                        "</td>
                                        <td class='mw-input'>" .
-                                       Xml::input( 'log-comment', 50, '',
+                                       Xml::input( 'log-comment', 50, 
+                                               ( $this->sourceName == 'upload' ? $this->logcomment : '' ),
                                                array( 'id' => 'mw-import-comment', 'type' => 'text' ) ) . ' ' .
                                        "</td>
                                </tr>
@@ -430,7 +432,8 @@ class SpecialImport extends SpecialPage {
                                        Xml::label( $this->msg( 'import-comment' )->text(), 'mw-interwiki-comment' ) .
                                        "</td>
                                        <td class='mw-input'>" .
-                                       Xml::input( 'log-comment', 50, '',
+                                       Xml::input( 'log-comment', 50,
+                                               ( $this->sourceName == 'interwiki' ? $this->logcomment : '' ),
                                                array( 'id' => 'mw-interwiki-comment', 'type' => 'text' ) ) . ' ' .
                                        "</td>
                                </tr>