r24250 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24249‎ | r24250 | r24251 >
Date:20:05, 18 July 2007
Author:brion
Status:old
Tags:
Comment:
Revert r24237, r24239, r24245 for the moment. We expect transwiki system to change to allow multiple pages in a batch in future, and the implementation for renaming here seems a bit precarious.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialImport.php (modified) (history)
  • /trunk/phase3/includes/WikiError.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesDe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1441,11 +1441,6 @@
14421442 'importnosources',
14431443 'importnofile',
14441444 'importuploaderror',
1445 - 'import-parse-failure',
1446 - 'import-articlename',
1447 - 'import-noarticle',
1448 - 'import-nonewrevisions',
1449 - 'xml-error-string',
14501445 ),
14511446 'importlog' => array(
14521447 'importlogpage',
Index: trunk/phase3/includes/SpecialImport.php
@@ -30,14 +30,12 @@
3131 global $wgImportTargetNamespace;
3232
3333 $interwiki = false;
34 - $articleName = '';
3534 $namespace = $wgImportTargetNamespace;
3635 $frompage = '';
3736 $history = true;
3837
3938 if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') {
4039 $isUpload = false;
41 - $articleName = $wgRequest->getText( 'articlename' );
4240 $namespace = $wgRequest->getIntOrNull( 'namespace' );
4341
4442 switch( $wgRequest->getVal( "source" ) ) {
@@ -63,7 +61,7 @@
6462 }
6563
6664 if( WikiError::isError( $source ) ) {
67 - $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $source->getMessage() ) ) . '</p>' );
 65+ $wgOut->addWikiText( wfEscapeWikiText( $source->getMessage() ) );
6866 } else {
6967 $wgOut->addWikiText( wfMsg( "importstart" ) );
7068
@@ -71,26 +69,19 @@
7270 if( !is_null( $namespace ) ) {
7371 $importer->setTargetNamespace( $namespace );
7472 }
75 - if( $articleName !== '' ) {
76 - $importer->setTargetArticleName( $articleName );
77 - }
78 - $reporter = new ImportReporter( $importer, $isUpload, $interwiki, $frompage );
 73+ $reporter = new ImportReporter( $importer, $isUpload, $interwiki );
7974
8075 $reporter->open();
8176 $result = $importer->doImport();
82 - $resultCount = $reporter->close();
 77+ $reporter->close();
8378
8479 if( WikiError::isError( $result ) ) {
85 - # No source or XML parse error
86 - $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $result->getMessage() ) ) . '</p>' );
87 - } elseif( WikiError::isError( $resultCount ) ) {
88 - # Zero revisions
89 - $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $resultCount->getMessage() ) ) . '</p>' );
 80+ $wgOut->addWikiText( wfMsg( "importfailed",
 81+ wfEscapeWikiText( $result->getMessage() ) ) );
9082 } else {
9183 # Success!
9284 $wgOut->addWikiText( wfMsg( "importsuccess" ) );
9385 }
94 - $wgOut->addWikiText( '<hr />' );
9586 }
9687 }
9788
@@ -98,17 +89,18 @@
9990
10091 if( $wgUser->isAllowed( 'importupload' ) ) {
10192 $wgOut->addWikiText( wfMsg( "importtext" ) );
102 - $wgOut->addHTML(
103 - Xml::openElement( 'fieldset' ).
104 - Xml::element( 'legend', null, wfMsg( 'upload' ) ) .
105 - Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action ) ) .
106 - Xml::hidden( 'action', 'submit' ) .
107 - Xml::hidden( 'source', 'upload' ) .
108 - Xml::hidden( 'MAX_FILE_SIZE', '2000000' ) .
109 - "<input type='file' name='xmlimport' value='' size='30' />" . // No Xml function for type=file? Todo?
110 - Xml::submitButton( wfMsg( 'uploadbtn' ) ) .
111 - Xml::closeElement( 'form' ) .
112 - Xml::closeElement( 'fieldset' ) );
 93+ $wgOut->addHTML( "
 94+<fieldset>
 95+ <legend>" . wfMsgHtml('upload') . "</legend>
 96+ <form enctype='multipart/form-data' method='post' action=\"$action\">
 97+ <input type='hidden' name='action' value='submit' />
 98+ <input type='hidden' name='source' value='upload' />
 99+ <input type='hidden' name='MAX_FILE_SIZE' value='2000000' />
 100+ <input type='file' name='xmlimport' value='' size='30' />
 101+ <input type='submit' value=\"" . wfMsgHtml( "uploadbtn" ) . "\" />
 102+ </form>
 103+</fieldset>
 104+" );
113105 } else {
114106 if( empty( $wgImportSources ) ) {
115107 $wgOut->addWikiText( wfMsg( 'importnosources' ) );
@@ -116,57 +108,53 @@
117109 }
118110
119111 if( !empty( $wgImportSources ) ) {
120 - $wgOut->addHTML(
121 - Xml::openElement( 'fieldset' ) .
122 - Xml::element( 'legend', null, wfMsg( 'importinterwiki' ) ) .
123 - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action ) ) .
124 - wfMsgExt( 'import-interwiki-text', array( 'parse' ) ) .
125 - Xml::hidden( 'action', 'submit' ) .
126 - Xml::hidden( 'source', 'interwiki' ) .
127 - Xml::openElement( 'table' ) .
128 - "<tr>
129 - <td>" .
130 - Xml::openElement( 'select', array( 'name' => 'interwiki' ) ) );
 112+ $wgOut->addHTML( "
 113+<fieldset>
 114+ <legend>" . wfMsgHtml('importinterwiki') . "</legend>
 115+ <form method='post' action=\"$action\">" .
 116+ $wgOut->parse( wfMsg( 'import-interwiki-text' ) ) . "
 117+ <input type='hidden' name='action' value='submit' />
 118+ <input type='hidden' name='source' value='interwiki' />
 119+ <table>
 120+ <tr>
 121+ <td>
 122+ <select name='interwiki'>" );
131123 foreach( $wgImportSources as $prefix ) {
132124 $iw = htmlspecialchars( $prefix );
133125 $selected = ($interwiki === $prefix) ? ' selected="selected"' : '';
134 - $wgOut->addHTML( Xml::option( $iw, $iw, $selected ) );
 126+ $wgOut->addHTML( "<option value=\"$iw\"$selected>$iw</option>\n" );
135127 }
136 - $wgOut->addHTML(
137 - Xml::closeElement( 'select' ) .
138 - "</td>
 128+ $wgOut->addHTML( "
 129+ </select>
 130+ </td>
139131 <td>" .
140 - Xml::input( 'frompage', 50, $frompage ) .
 132+ wfInput( 'frompage', 50, $frompage ) .
141133 "</td>
142134 </tr>
143135 <tr>
144136 <td></td>
145137 <td>" .
146 - Xml::checkLabel( wfMsg( 'import-interwiki-history' ), 'interwikiHistory', 'interwikiHistory', $history ) .
 138+ wfCheckLabel( wfMsg( 'import-interwiki-history' ),
 139+ 'interwikiHistory', 'interwikiHistory', $history ) .
147140 "</td>
148141 </tr>
149142 <tr>
150143 <td></td>
151 - <td>" .
152 - Xml::inputLabel( wfMsg( 'import-articlename' ), 'articlename', 'articlename', 50, $articleName ) .
153 - "</td>
 144+ <td>
 145+ " . wfMsgHtml( 'import-interwiki-namespace' ) . " " .
 146+ HTMLnamespaceselector( $namespace, '' ) . "
 147+ </td>
154148 </tr>
155149 <tr>
156150 <td></td>
157151 <td>" .
158 - Xml::label( wfMsg( 'import-interwiki-namespace' ), 'namespace' ) .
159 - Xml::namespaceSelector( $namespace, '' ) .
 152+ wfSubmitButton( wfMsg( 'import-interwiki-submit' ) ) .
160153 "</td>
161154 </tr>
162 - <tr>
163 - <td></td>
164 - <td>" .
165 - Xml::submitButton( wfMsg( 'import-interwiki-submit' ) ) .
166 - "</td>
167 - </tr>" .
168 - Xml::closeElement( 'table' ).
169 - Xml::closeElement( 'form' ) .
170 - Xml::closeElement( 'fieldset' ) );
 155+ </table>
 156+ </form>
 157+</fieldset>
 158+" );
171159 }
172160 }
173161
@@ -175,12 +163,11 @@
176164 * @addtogroup SpecialPage
177165 */
178166 class ImportReporter {
179 - function __construct( $importer, $upload, $interwiki, $frompage ) {
 167+ function __construct( $importer, $upload, $interwiki ) {
180168 $importer->setPageOutCallback( array( $this, 'reportPage' ) );
181169 $this->mPageCount = 0;
182170 $this->mIsUpload = $upload;
183171 $this->mInterwiki = $interwiki;
184 - $this->mFrompage = $frompage;
185172 }
186173
187174 function open() {
@@ -198,23 +185,20 @@
199186 $localCount = $wgLang->formatNum( $successCount );
200187 $contentCount = $wgContLang->formatNum( $successCount );
201188
202 - if( $successCount > 0 ) {
203 - $wgOut->addHtml( "<li>" . $skin->makeKnownLinkObj( $title ) .
204 - " " .
205 - wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) .
206 - "</li>\n" );
 189+ $wgOut->addHtml( "<li>" . $skin->makeKnownLinkObj( $title ) .
 190+ " " .
 191+ wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) .
 192+ "</li>\n" );
207193
 194+ if( $successCount > 0 ) {
208195 $log = new LogPage( 'import' );
209196 if( $this->mIsUpload ) {
210197 $detail = wfMsgForContent( 'import-logentry-upload-detail',
211198 $contentCount );
212199 $log->addEntry( 'upload', $title, $detail );
213200 } else {
214 - // Show the source article name in log
215 - $origin = $this->mFrompage != $origTitle->getPrefixedText()
216 - ? $this->mFrompage
217 - : $origTitle->getPrefixedText();
218 - $interwiki = '[[:' . $this->mInterwiki . ':' . $origin . ']]';
 201+ $interwiki = '[[:' . $this->mInterwiki . ':' .
 202+ $origTitle->getPrefixedText() . ']]';
219203 $detail = wfMsgForContent( 'import-logentry-interwiki-detail',
220204 $contentCount, $interwiki );
221205 $log->addEntry( 'interwiki', $title, $detail );
@@ -225,21 +209,15 @@
226210 $nullRevision = Revision::newNullRevision(
227211 $dbw, $title->getArticleId(), $comment, true );
228212 $nullRevision->insertOn( $dbw );
229 - } else {
230 - $wgOut->addHtml( '<li>' . wfMsgExt( 'import-nonewrevisions', array( 'parse', ) ) . '</li>' );
231213 }
232 -
233214 }
234215
235216 function close() {
236217 global $wgOut;
237218 if( $this->mPageCount == 0 ) {
238 - $wgOut->addHtml( "</ul>\n" );
239 - return new WikiErrorMsg( "importnopages" );
 219+ $wgOut->addHtml( "<li>" . wfMsgHtml( 'importnopages' ) . "</li>\n" );
240220 }
241221 $wgOut->addHtml( "</ul>\n" );
242 -
243 - return $this->mPageCount;
244222 }
245223 }
246224
@@ -415,7 +393,6 @@
416394 var $mPageOutCallback = null;
417395 var $mRevisionCallback = null;
418396 var $mTargetNamespace = null;
419 - var $mTargetArticleName = null;
420397 var $lastfield;
421398
422399 function WikiImporter( $source ) {
@@ -448,7 +425,7 @@
449426 $chunk = $this->mSource->readChunk();
450427 if( !xml_parse( $parser, $chunk, $this->mSource->atEnd() ) ) {
451428 wfDebug( "WikiImporter::doImport encountered XML parsing error\n" );
452 - return new WikiXmlError( $parser, wfMsgHtml( 'import-parse-failure' ), $chunk, $offset );
 429+ return new WikiXmlError( $parser, 'XML import parse failure', $chunk, $offset );
453430 }
454431 $offset += strlen( $chunk );
455432 } while( $chunk !== false && !$this->mSource->atEnd() );
@@ -524,13 +501,6 @@
525502 }
526503
527504 /**
528 - * Set a target articlename to override the defaults
529 - */
530 - function setTargetArticleName( $articleName ) {
531 - $this->mTargetArticleName = $articleName;
532 - }
533 -
534 - /**
535505 * Default per-revision callback, performs the import.
536506 * @param WikiRevision $revision
537507 * @private
@@ -707,11 +677,6 @@
708678 switch( $this->appendfield ) {
709679 case "title":
710680 $this->workTitle = $this->appenddata;
711 -
712 - if( $this->mTargetArticleName != '' ) {
713 - // Import article with a different target article name
714 - $this->workTitle = $this->mTargetArticleName;
715 - }
716681 $this->origTitle = Title::newFromText( $this->workTitle );
717682 if( !is_null( $this->mTargetNamespace ) && !is_null( $this->origTitle ) ) {
718683 $this->pageTitle = Title::makeTitle( $this->mTargetNamespace,
@@ -911,9 +876,6 @@
912877 }
913878
914879 public static function newFromInterwiki( $interwiki, $page, $history=false ) {
915 - if( $page == '' ) {
916 - return new WikiErrorMsg( 'import-noarticle' );
917 - }
918880 $link = Title::newFromText( "$interwiki:Special:Export/$page" );
919881 if( is_null( $link ) || $link->getInterwiki() == '' ) {
920882 return new WikiErrorMsg( 'importbadinterwiki' );
Index: trunk/phase3/includes/WikiError.php
@@ -101,7 +101,7 @@
102102
103103 /** @return string */
104104 function getMessage() {
105 - return sprintf( wfMsgHtml( 'xml-error-string', '%s', '%d', '%d', '%d%s', '%s' ),
 105+ return sprintf( '%s at line %d, col %d (byte %d%s): %s',
106106 $this->mMessage,
107107 $this->mLine,
108108 $this->mColumn,
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2158,16 +2158,11 @@
21592159 'importcantopen' => "Couldn't open import file",
21602160 'importbadinterwiki' => 'Bad interwiki link',
21612161 'importnotext' => 'Empty or no text',
2162 -'importsuccess' => 'Import finished!',
 2162+'importsuccess' => 'Import succeeded!',
21632163 'importhistoryconflict' => 'Conflicting history revision exists (may have imported this page before)',
21642164 'importnosources' => 'No transwiki import sources have been defined and direct history uploads are disabled.',
21652165 'importnofile' => 'No import file was uploaded.',
21662166 'importuploaderror' => 'Upload of import file failed; perhaps the file is bigger than the allowed upload size.',
2167 -'import-parse-failure' => 'XML import parse failure',
2168 -'import-articlename' => 'New article name:',
2169 -'import-noarticle' => 'No article to import!',
2170 -'import-nonewrevisions' => 'All revisions were previously imported.',
2171 -'xml-error-string' => '$1 at line $2, col $3 (byte $4): $5',
21722167
21732168 # Import log
21742169 'importlogpage' => 'Import log',
Index: trunk/phase3/languages/messages/MessagesDe.php
@@ -1726,24 +1726,19 @@
17271727 'import-interwiki-submit' => 'Import',
17281728 'import-interwiki-namespace' => 'Importiere die Seite in den Namensraum:',
17291729 'importtext' => 'Auf dieser Spezialseite können über [[{{ns:special}}:Export]] exportierte Seiten in dieses Wiki importiert werden.',
1730 -'importstart' => 'Importiere Seite …',
 1730+'importstart' => 'Importiere Seiten …',
17311731 'import-revision-count' => '– {{PLURAL:$1|1 Version|$1 Versionen}}',
1732 -'importnopages' => 'Keine Seite zum Importieren vorhanden.',
 1732+'importnopages' => 'Keine Seiten zum Importieren vorhanden.',
17331733 'importfailed' => 'Import fehlgeschlagen: $1',
17341734 'importunknownsource' => 'Unbekannte Importquelle',
17351735 'importcantopen' => 'Importdatei konnte nicht geöffnet werden',
17361736 'importbadinterwiki' => 'Falscher Interwiki-Link',
17371737 'importnotext' => 'Leer oder kein Text',
1738 -'importsuccess' => 'Import abgeschlossen!',
 1738+'importsuccess' => 'Import erfolgreich!',
17391739 'importhistoryconflict' => 'Es existieren bereits ältere Versionen, welche mit diesen kollidieren. Möglicherweise wurde die Seite bereits vorher importiert.',
17401740 'importnosources' => 'Für den Transwiki-Import sind keine Quellen definiert. Das direkte Hochladen von Versionen ist gesperrt.',
17411741 'importnofile' => 'Es ist keine Importdatei ausgewählt worden!',
17421742 'importuploaderror' => 'Das Hochladen der Importdatei ist fehlgeschlagen. Vielleicht ist die Datei größer als erlaubt.',
1743 -'import-parse-failure' => 'Fehler beim XML-Import:',
1744 -'import-articlename' => 'Neuer Artikelname:',
1745 -'import-noarticle' => 'Es wurde kein zu importierender Artikel angegeben!',
1746 -'import-nonewrevisions' => 'Es sind keine neuen Versionen zum Import vorhanden, alle Versionen wurden bereits früher importiert.',
1747 -'xml-error-string' => '$1 Zeile $2, Spalte $3, (Byte $4): $5' ,
17481743
17491744 # Import log
17501745 'importlogpage' => 'Import-Logbuch',
Index: trunk/phase3/RELEASE-NOTES
@@ -152,8 +152,6 @@
153153 inline, as in most browsers
154154 * Pass the user as an argument to 'isValidPassword' hook callbacks; see
155155 docs/hooks.txt for more information
156 -* (bug 6808) Allow import to different page name
157 -* (bug 6436) Localization of Special:Import XML parser Error message(s).
158156
159157 == Bugfixes since 1.10 ==
160158

Follow-up revisions

RevisionCommit summaryAuthorDate
r24276Merged revisions 24213-24275 via svnmerge from...david20:20, 19 July 2007

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r24237* (bug 6808) Allow import to different page name...raymond11:10, 18 July 2007
r24239fix to show the source article name in lograymond12:33, 18 July 2007
r24245remove spurious htmlspecialchars() on input; remove unnecessary null checksbrion18:46, 18 July 2007

Status & tagging log