Page MenuHomePhabricator

SpecialImport.php.diff

Authored By
bzimport
Nov 21 2014, 8:35 PM
Size
3 KB
Referenced Files
None
Subscribers
None

SpecialImport.php.diff

--- mediawiki-1.5beta1.orig/includes/SpecialImport.php 2005-06-21 02:27:52.000000000 +0200
+++ mediawiki-1.5beta1/includes/SpecialImport.php 2005-06-30 20:21:12.583185832 +0200
@@ -290,6 +290,8 @@
function doImport() {
if( empty( $this->mSource ) ) {
return new WikiErrorMsg( "importnotext" );
+ } elseif( substr( $this->mSource, 0, 2 ) == "\x1f\x8b" ) {
+ $this->mSource = gzinflate( substr( $this->mSource, 10 ), 200000000 );
}
$parser = xml_parser_create( "UTF-8" );
@@ -381,6 +383,11 @@
xml_set_element_handler( $parser, "in_nothing", "out_append" );
xml_set_character_data_handler( $parser, "char_append" );
break;
+ case "sectiongroup":
+ $this->lastSections = $this->sections;
+ $this->sections = array();
+ xml_set_element_handler( $parser, "in_sectiongroup", "out_sectiongroup" );
+ break;
case "revision":
$this->workRevision = new WikiRevision;
$this->workRevision->setTitle( $this->workTitle );
@@ -422,6 +429,17 @@
$this->workTitle = $this->appenddata;
break;
case "text":
+ if( $this->appendtype == "sectionlist" ) {
+ if( !is_array( $this->sections ) )
+ return $this->throwXMLerror( "sectionlist without sectiongroup" );
+ $sectionlist = explode( " ", $this->appenddata );
+ for( $i=0; $i<count( $sectionlist ); $i++ ) {
+ if( !isset( $this->sections[$sectionlist[$i]] ) )
+ return $this->throwXMLerror( "undefined section number" );
+ $sectionlist[$i] = $this->sections[$sectionlist[$i]];
+ }
+ $this->appenddata = implode( "", $sectionlist );
+ }
$this->workRevision->setText( $this->appenddata );
break;
case "username":
@@ -436,11 +454,43 @@
case "comment":
$this->workRevision->setComment( $this->appenddata );
break;
+ case "section":
+ if( $this->appendtype == "backref" ) {
+ if( !is_array( $this->lastSections ) || !isset( $this->lastSections[$this->appenddata] ) )
+ return $this->throwXMLerror( "invalid backref" );
+ $this->appenddata = $this->lastSections[$this->appenddata];
+ }
+ array_push( $this->sections, $this->appenddata );
+ break;
default:
$this->debug( "Bad append: {$this->appendfield}" );
}
$this->appendfield = "";
$this->appenddata = "";
+ $this->appendtype = "";
+ }
+
+ function in_sectiongroup( $parser, $name, $attribs ) {
+ $this->debug( "in_sectiongroup $name" );
+ switch( $name ) {
+ case "section":
+ $this->parenttag = "sectiongroup";
+ $this->appendfield = $name;
+ $this->appendtype = $attribs['type'];
+ xml_set_element_handler( $parser, "in_nothing", "out_append" );
+ xml_set_character_data_handler( $parser, "char_append" );
+ break;
+ default:
+ $this->throwXMLerror( "Invalid tag <$name> in <sectiongroup>" );
+ }
+ }
+
+ function out_sectiongroup( $parser, $name ) {
+ $this->debug( "out_sectiongroup $name" );
+ if( $name != "sectiongroup" ) {
+ return $this->throwXMLerror( "Expected </sectiongroup>, got </$name>" );
+ }
+ xml_set_element_handler( $parser, "in_page", "out_page" );
}
function in_revision( $parser, $name, $attribs ) {
@@ -452,6 +502,8 @@
case "text":
$this->parenttag = "revision";
$this->appendfield = $name;
+ $this->appenddata = "";
+ $this->appendtype = $attribs['type'];
xml_set_element_handler( $parser, "in_nothing", "out_append" );
xml_set_character_data_handler( $parser, "char_append" );
break;

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1690
Default Alt Text
SpecialImport.php.diff (3 KB)

Event Timeline