diff options
Diffstat (limited to 'includes/SpecialImport.php')
-rw-r--r-- | includes/SpecialImport.php | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index 07b2df54afa6..728f80c16774 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -128,6 +128,7 @@ class WikiRevision { var $user_text = ""; var $text = ""; var $comment = ""; + var $minor = false; function setTitle( $text ) { $this->title = Title::newFromText( $text ); @@ -154,6 +155,10 @@ class WikiRevision { $this->comment = $text; } + function setMinor( $minor ) { + $this->minor = (bool)$minor; + } + function getTitle() { return $this->title; } @@ -173,6 +178,10 @@ class WikiRevision { function getComment() { return $this->comment; } + + function getMinor() { + return $this->minor; + } function importOldRevision() { $fname = "WikiImporter::importOldRevision"; @@ -188,6 +197,10 @@ class WikiRevision { $userText = $this->getUser(); } + // avoid memory leak...? + global $wgLinkCache; + $wgLinkCache->clear(); + $article = new Article( $this->title ); $pageId = $article->getId(); if( $pageId == 0 ) { @@ -211,7 +224,7 @@ class WikiRevision { 'user' => $userId, 'user_text' => $userText, 'timestamp' => $this->timestamp, - 'minor_edit' => 0 + 'minor_edit' => $this->minor, ) ); $revId = $revision->insertOn( $dbw ); $article->updateIfNewerOn( $dbw, $revision ); @@ -239,6 +252,7 @@ class WikiImporter { function throwXmlError( $err ) { $this->debug( "FAILURE: $err" ); + wfDebug( "WikiImporter XML error: $err\n" ); } # -------------- @@ -253,14 +267,17 @@ class WikiImporter { # case folding violates XML standard, turn it off xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false ); - xml_set_object( $parser, &$this ); + xml_set_object( $parser, $this ); xml_set_element_handler( $parser, "in_start", "" ); + $offset = 0; // for context extraction on error reporting do { $chunk = $this->mSource->readChunk(); if( !xml_parse( $parser, $chunk, $this->mSource->atEnd() ) ) { - return new WikiXmlError( $parser ); + wfDebug( "WikiImporter::doImport encountered XML parsing error\n" ); + return new WikiXmlError( $parser, 'XML import parse failure', $chunk, $offset ); } + $offset += strlen( $chunk ); } while( $chunk !== false && !$this->mSource->atEnd() ); xml_parser_free( $parser ); @@ -380,6 +397,7 @@ class WikiImporter { $this->debug( "in_siteinfo $name" ); switch( $name ) { case "sitename": + case "base": case "generator": case "case": case "namespaces": @@ -466,6 +484,9 @@ class WikiImporter { case "comment": $this->workRevision->setComment( $this->appenddata ); break; + case "minor": + $this->workRevision->setMinor( true ); + break; default: $this->debug( "Bad append: {$this->appendfield}" ); } @@ -479,6 +500,7 @@ class WikiImporter { case "id": case "timestamp": case "comment": + case "minor": case "text": $this->parenttag = "revision"; $this->appendfield = $name; @@ -500,9 +522,8 @@ class WikiImporter { } xml_set_element_handler( $parser, "in_page", "out_page" ); - $out = call_user_func( $this->mRevisionCallback, - &$this->workRevision, - &$this ); + $out = call_user_func_array( $this->mRevisionCallback, + array( &$this->workRevision, &$this ) ); if( !empty( $out ) ) { global $wgOut; $wgOut->addHTML( "<li>" . $out . "</li>\n" ); @@ -514,6 +535,7 @@ class WikiImporter { switch( $name ) { case "username": case "ip": + case "id": $this->parenttag = "contributor"; $this->appendfield = $name; xml_set_element_handler( $parser, "in_nothing", "out_append" ); |