3 * MediaWiki page data importer
4 * Copyright (C) 2003,2005 Brion Vibber <brion@pobox.com>
5 * http://www.mediawiki.org/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
22 * @addtogroup SpecialPage
28 function wfSpecialImport( $page = '' ) {
29 global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources;
30 global $wgImportTargetNamespace;
33 $namespace = $wgImportTargetNamespace;
38 $wgOut->readOnlyPage();
42 if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') {
44 $namespace = $wgRequest->getIntOrNull( 'namespace' );
46 switch( $wgRequest->getVal( "source" ) ) {
49 if( $wgUser->isAllowed( 'importupload' ) ) {
50 $source = ImportStreamSource
::newFromUpload( "xmlimport" );
52 return $wgOut->permissionRequired( 'importupload' );
56 $interwiki = $wgRequest->getVal( 'interwiki' );
57 $history = $wgRequest->getCheck( 'interwikiHistory' );
58 $frompage = $wgRequest->getText( "frompage" );
59 $source = ImportStreamSource
::newFromInterwiki(
65 $source = new WikiErrorMsg( "importunknownsource" );
68 if( WikiError
::isError( $source ) ) {
69 $wgOut->wrapWikiMsg( '<p class="error">$1</p>', array( 'importfailed', $source->getMessage() ) );
71 $wgOut->addWikiMsg( "importstart" );
73 $importer = new WikiImporter( $source );
74 if( !is_null( $namespace ) ) {
75 $importer->setTargetNamespace( $namespace );
77 $reporter = new ImportReporter( $importer, $isUpload, $interwiki );
80 $result = $importer->doImport();
81 $resultCount = $reporter->close();
83 if( WikiError
::isError( $result ) ) {
84 # No source or XML parse error
85 $wgOut->wrapWikiMsg( '<p class="error">$1</p>', array( 'importfailed', $result->getMessage() ) );
86 } elseif( WikiError
::isError( $resultCount ) ) {
88 $wgOut->wrapWikiMsg( '<p class="error">$1</p>', array( 'importfailed', $resultCount->getMessage() ) );
91 $wgOut->addWikiMsg( 'importsuccess' );
93 $wgOut->addWikiText( '<hr />' );
97 $action = $wgTitle->getLocalUrl( 'action=submit' );
99 if( $wgUser->isAllowed( 'importupload' ) ) {
100 $wgOut->addWikiMsg( "importtext" );
102 Xml
::openElement( 'fieldset' ).
103 Xml
::element( 'legend', null, wfMsg( 'upload' ) ) .
104 Xml
::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action ) ) .
105 Xml
::hidden( 'action', 'submit' ) .
106 Xml
::hidden( 'source', 'upload' ) .
107 "<input type='file' name='xmlimport' value='' size='30' />" . // No Xml function for type=file? Todo?
108 Xml
::submitButton( wfMsg( 'uploadbtn' ) ) .
109 Xml
::closeElement( 'form' ) .
110 Xml
::closeElement( 'fieldset' )
113 if( empty( $wgImportSources ) ) {
114 $wgOut->addWikiMsg( 'importnosources' );
118 if( !empty( $wgImportSources ) ) {
120 Xml
::openElement( 'fieldset' ) .
121 Xml
::element( 'legend', null, wfMsg( 'importinterwiki' ) ) .
122 Xml
::openElement( 'form', array( 'method' => 'post', 'action' => $action ) ) .
123 wfMsgExt( 'import-interwiki-text', array( 'parse' ) ) .
124 Xml
::hidden( 'action', 'submit' ) .
125 Xml
::hidden( 'source', 'interwiki' ) .
126 Xml
::openElement( 'table' ) .
129 Xml
::openElement( 'select', array( 'name' => 'interwiki' ) )
131 foreach( $wgImportSources as $prefix ) {
132 $iw = htmlspecialchars( $prefix );
133 $selected = ($interwiki === $prefix) ?
' selected="selected"' : '';
134 $wgOut->addHTML( Xml
::option( $iw, $iw, $selected ) );
137 Xml
::closeElement( 'select' ) .
140 Xml
::input( 'frompage', 50, $frompage ) .
147 Xml
::checkLabel( wfMsg( 'import-interwiki-history' ), 'interwikiHistory', 'interwikiHistory', $history ) .
154 Xml
::label( wfMsg( 'import-interwiki-namespace' ), 'namespace' ) .
155 Xml
::namespaceSelector( $namespace, '' ) .
162 Xml
::submitButton( wfMsg( 'import-interwiki-submit' ) ) .
165 Xml
::closeElement( 'table' ).
166 Xml
::closeElement( 'form' ) .
167 Xml
::closeElement( 'fieldset' )
174 * @addtogroup SpecialPage
176 class ImportReporter
{
177 function __construct( $importer, $upload, $interwiki ) {
178 $importer->setPageOutCallback( array( $this, 'reportPage' ) );
179 $this->mPageCount
= 0;
180 $this->mIsUpload
= $upload;
181 $this->mInterwiki
= $interwiki;
186 $wgOut->addHtml( "<ul>\n" );
189 function reportPage( $title, $origTitle, $revisionCount, $successCount ) {
190 global $wgOut, $wgUser, $wgLang, $wgContLang;
192 $skin = $wgUser->getSkin();
196 $localCount = $wgLang->formatNum( $successCount );
197 $contentCount = $wgContLang->formatNum( $successCount );
199 if( $successCount > 0 ) {
200 $wgOut->addHtml( "<li>" . $skin->makeKnownLinkObj( $title ) . " " .
201 wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) .
205 $log = new LogPage( 'import' );
206 if( $this->mIsUpload
) {
207 $detail = wfMsgExt( 'import-logentry-upload-detail', array( 'content', 'parsemag' ),
209 $log->addEntry( 'upload', $title, $detail );
211 $interwiki = '[[:' . $this->mInterwiki
. ':' .
212 $origTitle->getPrefixedText() . ']]';
213 $detail = wfMsgExt( 'import-logentry-interwiki-detail', array( 'content', 'parsemag' ),
214 $contentCount, $interwiki );
215 $log->addEntry( 'interwiki', $title, $detail );
218 $comment = $detail; // quick
219 $dbw = wfGetDB( DB_MASTER
);
220 $nullRevision = Revision
::newNullRevision(
221 $dbw, $title->getArticleId(), $comment, true );
222 $nullRevision->insertOn( $dbw );
224 $article = new Article( $title );
225 $article->updateRevisionOn( $dbw, $nullRevision );
227 $wgOut->addHtml( '<li>' . wfMsgHtml( 'import-nonewrevisions' ) . '</li>' );
233 if( $this->mPageCount
== 0 ) {
234 $wgOut->addHtml( "</ul>\n" );
235 return new WikiErrorMsg( "importnopages" );
237 $wgOut->addHtml( "</ul>\n" );
239 return $this->mPageCount
;
245 * @addtogroup SpecialPage
250 var $timestamp = "20010115000000";
257 function setTitle( $title ) {
258 if( is_object( $title ) ) {
259 $this->title
= $title;
260 } elseif( is_null( $title ) ) {
261 throw new MWException( "WikiRevision given a null title in import. You may need to adjust \$wgLegalTitleChars." );
263 throw new MWException( "WikiRevision given non-object title in import." );
267 function setID( $id ) {
271 function setTimestamp( $ts ) {
272 # 2003-08-05T18:30:02Z
273 $this->timestamp
= wfTimestamp( TS_MW
, $ts );
276 function setUsername( $user ) {
277 $this->user_text
= $user;
280 function setUserIP( $ip ) {
281 $this->user_text
= $ip;
284 function setText( $text ) {
288 function setComment( $text ) {
289 $this->comment
= $text;
292 function setMinor( $minor ) {
293 $this->minor
= (bool)$minor;
296 function getTitle() {
304 function getTimestamp() {
305 return $this->timestamp
;
309 return $this->user_text
;
316 function getComment() {
317 return $this->comment
;
320 function getMinor() {
324 function importOldRevision() {
325 $dbw = wfGetDB( DB_MASTER
);
327 # Sneak a single revision into place
328 $user = User
::newFromName( $this->getUser() );
330 $userId = intval( $user->getId() );
331 $userText = $user->getName();
334 $userText = $this->getUser();
337 // avoid memory leak...?
338 $linkCache =& LinkCache
::singleton();
341 $article = new Article( $this->title
);
342 $pageId = $article->getId();
344 # must create the page...
345 $pageId = $article->insertOn( $dbw );
350 $prior = Revision
::loadFromTimestamp( $dbw, $this->title
, $this->timestamp
);
351 if( !is_null( $prior ) ) {
352 // FIXME: this could fail slightly for multiple matches :P
353 wfDebug( __METHOD__
. ": skipping existing revision for [[" .
354 $this->title
->getPrefixedText() . "]], timestamp " .
355 $this->timestamp
. "\n" );
360 # FIXME: Use original rev_id optionally
361 # FIXME: blah blah blah
363 #if( $numrows > 0 ) {
364 # return wfMsg( "importhistoryconflict" );
368 $revision = new Revision( array(
370 'text' => $this->getText(),
371 'comment' => $this->getComment(),
373 'user_text' => $userText,
374 'timestamp' => $this->timestamp
,
375 'minor_edit' => $this->minor
,
377 $revId = $revision->insertOn( $dbw );
378 $changed = $article->updateIfNewerOn( $dbw, $revision );
381 wfDebug( __METHOD__
. ": running onArticleCreate\n" );
382 Article
::onArticleCreate( $this->title
);
384 wfDebug( __METHOD__
. ": running create updates\n" );
385 $article->createUpdates( $revision );
387 } elseif( $changed ) {
388 wfDebug( __METHOD__
. ": running onArticleEdit\n" );
389 Article
::onArticleEdit( $this->title
);
391 wfDebug( __METHOD__
. ": running edit updates\n" );
392 $article->editUpdates(
406 * implements Special:Import
407 * @addtogroup SpecialPage
411 var $mPageCallback = null;
412 var $mPageOutCallback = null;
413 var $mRevisionCallback = null;
414 var $mTargetNamespace = null;
417 function WikiImporter( $source ) {
418 $this->setRevisionCallback( array( &$this, "importRevision" ) );
419 $this->mSource
= $source;
422 function throwXmlError( $err ) {
423 $this->debug( "FAILURE: $err" );
424 wfDebug( "WikiImporter XML error: $err\n" );
429 function doImport() {
430 if( empty( $this->mSource
) ) {
431 return new WikiErrorMsg( "importnotext" );
434 $parser = xml_parser_create( "UTF-8" );
436 # case folding violates XML standard, turn it off
437 xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING
, false );
439 xml_set_object( $parser, $this );
440 xml_set_element_handler( $parser, "in_start", "" );
442 $offset = 0; // for context extraction on error reporting
444 $chunk = $this->mSource
->readChunk();
445 if( !xml_parse( $parser, $chunk, $this->mSource
->atEnd() ) ) {
446 wfDebug( "WikiImporter::doImport encountered XML parsing error\n" );
447 return new WikiXmlError( $parser, wfMsgHtml( 'import-parse-failure' ), $chunk, $offset );
449 $offset +
= strlen( $chunk );
450 } while( $chunk !== false && !$this->mSource
->atEnd() );
451 xml_parser_free( $parser );
456 function debug( $data ) {
457 #wfDebug( "IMPORT: $data\n" );
460 function notice( $data ) {
461 global $wgCommandLineMode;
462 if( $wgCommandLineMode ) {
466 $wgOut->addHTML( "<li>" . htmlspecialchars( $data ) . "</li>\n" );
471 * Sets the action to perform as each new page in the stream is reached.
472 * @param callable $callback
475 function setPageCallback( $callback ) {
476 $previous = $this->mPageCallback
;
477 $this->mPageCallback
= $callback;
482 * Sets the action to perform as each page in the stream is completed.
483 * Callback accepts the page title (as a Title object), a second object
484 * with the original title form (in case it's been overridden into a
485 * local namespace), and a count of revisions.
487 * @param callable $callback
490 function setPageOutCallback( $callback ) {
491 $previous = $this->mPageOutCallback
;
492 $this->mPageOutCallback
= $callback;
497 * Sets the action to perform as each page revision is reached.
498 * @param callable $callback
501 function setRevisionCallback( $callback ) {
502 $previous = $this->mRevisionCallback
;
503 $this->mRevisionCallback
= $callback;
508 * Set a target namespace to override the defaults
510 function setTargetNamespace( $namespace ) {
511 if( is_null( $namespace ) ) {
512 // Don't override namespaces
513 $this->mTargetNamespace
= null;
514 } elseif( $namespace >= 0 ) {
515 // FIXME: Check for validity
516 $this->mTargetNamespace
= intval( $namespace );
523 * Default per-revision callback, performs the import.
524 * @param WikiRevision $revision
527 function importRevision( &$revision ) {
528 $dbw = wfGetDB( DB_MASTER
);
529 return $dbw->deadlockLoop( array( &$revision, 'importOldRevision' ) );
533 * Alternate per-revision callback, for debugging.
534 * @param WikiRevision $revision
537 function debugRevisionHandler( &$revision ) {
538 $this->debug( "Got revision:" );
539 if( is_object( $revision->title
) ) {
540 $this->debug( "-- Title: " . $revision->title
->getPrefixedText() );
542 $this->debug( "-- Title: <invalid>" );
544 $this->debug( "-- User: " . $revision->user_text
);
545 $this->debug( "-- Timestamp: " . $revision->timestamp
);
546 $this->debug( "-- Comment: " . $revision->comment
);
547 $this->debug( "-- Text: " . $revision->text
);
551 * Notify the callback function when a new <page> is reached.
552 * @param Title $title
555 function pageCallback( $title ) {
556 if( is_callable( $this->mPageCallback
) ) {
557 call_user_func( $this->mPageCallback
, $title );
562 * Notify the callback function when a </page> is closed.
563 * @param Title $title
564 * @param Title $origTitle
565 * @param int $revisionCount
566 * @param int $successCount number of revisions for which callback returned true
569 function pageOutCallback( $title, $origTitle, $revisionCount, $successCount ) {
570 if( is_callable( $this->mPageOutCallback
) ) {
571 call_user_func( $this->mPageOutCallback
, $title, $origTitle,
572 $revisionCount, $successCount );
577 # XML parser callbacks from here out -- beware!
578 function donothing( $parser, $x, $y="" ) {
579 #$this->debug( "donothing" );
582 function in_start( $parser, $name, $attribs ) {
583 $this->debug( "in_start $name" );
584 if( $name != "mediawiki" ) {
585 return $this->throwXMLerror( "Expected <mediawiki>, got <$name>" );
587 xml_set_element_handler( $parser, "in_mediawiki", "out_mediawiki" );
590 function in_mediawiki( $parser, $name, $attribs ) {
591 $this->debug( "in_mediawiki $name" );
592 if( $name == 'siteinfo' ) {
593 xml_set_element_handler( $parser, "in_siteinfo", "out_siteinfo" );
594 } elseif( $name == 'page' ) {
595 $this->workRevisionCount
= 0;
596 $this->workSuccessCount
= 0;
597 xml_set_element_handler( $parser, "in_page", "out_page" );
599 return $this->throwXMLerror( "Expected <page>, got <$name>" );
602 function out_mediawiki( $parser, $name ) {
603 $this->debug( "out_mediawiki $name" );
604 if( $name != "mediawiki" ) {
605 return $this->throwXMLerror( "Expected </mediawiki>, got </$name>" );
607 xml_set_element_handler( $parser, "donothing", "donothing" );
611 function in_siteinfo( $parser, $name, $attribs ) {
613 $this->debug( "in_siteinfo $name" );
623 return $this->throwXMLerror( "Element <$name> not allowed in <siteinfo>." );
627 function out_siteinfo( $parser, $name ) {
628 if( $name == "siteinfo" ) {
629 xml_set_element_handler( $parser, "in_mediawiki", "out_mediawiki" );
634 function in_page( $parser, $name, $attribs ) {
635 $this->debug( "in_page $name" );
640 $this->appendfield
= $name;
641 $this->appenddata
= "";
642 $this->parenttag
= "page";
643 xml_set_element_handler( $parser, "in_nothing", "out_append" );
644 xml_set_character_data_handler( $parser, "char_append" );
647 if( is_object( $this->pageTitle
) ) {
648 $this->workRevision
= new WikiRevision
;
649 $this->workRevision
->setTitle( $this->pageTitle
);
650 $this->workRevisionCount++
;
652 // Skipping items due to invalid page title
653 $this->workRevision
= null;
655 xml_set_element_handler( $parser, "in_revision", "out_revision" );
658 return $this->throwXMLerror( "Element <$name> not allowed in a <page>." );
662 function out_page( $parser, $name ) {
663 $this->debug( "out_page $name" );
664 if( $name != "page" ) {
665 return $this->throwXMLerror( "Expected </page>, got </$name>" );
667 xml_set_element_handler( $parser, "in_mediawiki", "out_mediawiki" );
669 $this->pageOutCallback( $this->pageTitle
, $this->origTitle
,
670 $this->workRevisionCount
, $this->workSuccessCount
);
672 $this->workTitle
= null;
673 $this->workRevision
= null;
674 $this->workRevisionCount
= 0;
675 $this->workSuccessCount
= 0;
676 $this->pageTitle
= null;
677 $this->origTitle
= null;
680 function in_nothing( $parser, $name, $attribs ) {
681 $this->debug( "in_nothing $name" );
682 return $this->throwXMLerror( "No child elements allowed here; got <$name>" );
684 function char_append( $parser, $data ) {
685 $this->debug( "char_append '$data'" );
686 $this->appenddata
.= $data;
688 function out_append( $parser, $name ) {
689 $this->debug( "out_append $name" );
690 if( $name != $this->appendfield
) {
691 return $this->throwXMLerror( "Expected </{$this->appendfield}>, got </$name>" );
693 xml_set_element_handler( $parser, "in_$this->parenttag", "out_$this->parenttag" );
694 xml_set_character_data_handler( $parser, "donothing" );
696 switch( $this->appendfield
) {
698 $this->workTitle
= $this->appenddata
;
699 $this->origTitle
= Title
::newFromText( $this->workTitle
);
700 if( !is_null( $this->mTargetNamespace
) && !is_null( $this->origTitle
) ) {
701 $this->pageTitle
= Title
::makeTitle( $this->mTargetNamespace
,
702 $this->origTitle
->getDBkey() );
704 $this->pageTitle
= Title
::newFromText( $this->workTitle
);
706 if( is_null( $this->pageTitle
) ) {
707 // Invalid page title? Ignore the page
708 $this->notice( "Skipping invalid page title '$this->workTitle'" );
710 $this->pageCallback( $this->workTitle
);
714 if ( $this->parenttag
== 'revision' ) {
715 if( $this->workRevision
)
716 $this->workRevision
->setID( $this->appenddata
);
720 if( $this->workRevision
)
721 $this->workRevision
->setText( $this->appenddata
);
724 if( $this->workRevision
)
725 $this->workRevision
->setUsername( $this->appenddata
);
728 if( $this->workRevision
)
729 $this->workRevision
->setUserIP( $this->appenddata
);
732 if( $this->workRevision
)
733 $this->workRevision
->setTimestamp( $this->appenddata
);
736 if( $this->workRevision
)
737 $this->workRevision
->setComment( $this->appenddata
);
740 if( $this->workRevision
)
741 $this->workRevision
->setMinor( true );
744 $this->debug( "Bad append: {$this->appendfield}" );
746 $this->appendfield
= "";
747 $this->appenddata
= "";
750 function in_revision( $parser, $name, $attribs ) {
751 $this->debug( "in_revision $name" );
758 $this->parenttag
= "revision";
759 $this->appendfield
= $name;
760 xml_set_element_handler( $parser, "in_nothing", "out_append" );
761 xml_set_character_data_handler( $parser, "char_append" );
764 xml_set_element_handler( $parser, "in_contributor", "out_contributor" );
767 return $this->throwXMLerror( "Element <$name> not allowed in a <revision>." );
771 function out_revision( $parser, $name ) {
772 $this->debug( "out_revision $name" );
773 if( $name != "revision" ) {
774 return $this->throwXMLerror( "Expected </revision>, got </$name>" );
776 xml_set_element_handler( $parser, "in_page", "out_page" );
778 if( $this->workRevision
) {
779 $ok = call_user_func_array( $this->mRevisionCallback
,
780 array( &$this->workRevision
, &$this ) );
782 $this->workSuccessCount++
;
787 function in_contributor( $parser, $name, $attribs ) {
788 $this->debug( "in_contributor $name" );
793 $this->parenttag
= "contributor";
794 $this->appendfield
= $name;
795 xml_set_element_handler( $parser, "in_nothing", "out_append" );
796 xml_set_character_data_handler( $parser, "char_append" );
799 $this->throwXMLerror( "Invalid tag <$name> in <contributor>" );
803 function out_contributor( $parser, $name ) {
804 $this->debug( "out_contributor $name" );
805 if( $name != "contributor" ) {
806 return $this->throwXMLerror( "Expected </contributor>, got </$name>" );
808 xml_set_element_handler( $parser, "in_revision", "out_revision" );
814 * @todo document (e.g. one-sentence class description).
815 * @addtogroup SpecialPage
817 class ImportStringSource
{
818 function ImportStringSource( $string ) {
819 $this->mString
= $string;
820 $this->mRead
= false;
827 function readChunk() {
828 if( $this->atEnd() ) {
832 return $this->mString
;
838 * @todo document (e.g. one-sentence class description).
839 * @addtogroup SpecialPage
841 class ImportStreamSource
{
842 function ImportStreamSource( $handle ) {
843 $this->mHandle
= $handle;
847 return feof( $this->mHandle
);
850 function readChunk() {
851 return fread( $this->mHandle
, 32768 );
854 static function newFromFile( $filename ) {
855 $file = @fopen
( $filename, 'rt' );
857 return new WikiErrorMsg( "importcantopen" );
859 return new ImportStreamSource( $file );
862 static function newFromUpload( $fieldname = "xmlimport" ) {
863 $upload =& $_FILES[$fieldname];
865 if( !isset( $upload ) ||
!$upload['name'] ) {
866 return new WikiErrorMsg( 'importnofile' );
868 if( !empty( $upload['error'] ) ) {
869 switch($upload['error']){
870 case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini.
871 return new WikiErrorMsg( 'importuploaderrorsize' );
872 case 2: # The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
873 return new WikiErrorMsg( 'importuploaderrorsize' );
874 case 3: # The uploaded file was only partially uploaded
875 return new WikiErrorMsg( 'importuploaderrorpartial' );
876 case 6: #Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
877 return new WikiErrorMsg( 'importuploaderrortemp' );
878 # case else: # Currently impossible
882 $fname = $upload['tmp_name'];
883 if( is_uploaded_file( $fname ) ) {
884 return ImportStreamSource
::newFromFile( $fname );
886 return new WikiErrorMsg( 'importnofile' );
890 function newFromURL( $url, $method = 'GET' ) {
891 wfDebug( __METHOD__
. ": opening $url\n" );
892 # Use the standard HTTP fetch function; it times out
893 # quicker and sorts out user-agent problems which might
894 # otherwise prevent importing from large sites, such
895 # as the Wikimedia cluster, etc.
896 $data = Http
::request( $method, $url );
897 if( $data !== false ) {
899 fwrite( $file, $data );
902 return new ImportStreamSource( $file );
904 return new WikiErrorMsg( 'importcantopen' );
908 public static function newFromInterwiki( $interwiki, $page, $history=false ) {
910 return new WikiErrorMsg( 'import-noarticle' );
912 $link = Title
::newFromText( "$interwiki:Special:Export/$page" );
913 if( is_null( $link ) ||
$link->getInterwiki() == '' ) {
914 return new WikiErrorMsg( 'importbadinterwiki' );
916 $params = $history ?
'history=1' : '';
917 $url = $link->getFullUrl( $params );
918 # For interwikis, use POST to avoid redirects.
919 return ImportStreamSource
::newFromURL( $url, "POST" );