From 743f84403117060077c4731342b74b039a084cc2 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sat, 9 Apr 2011 14:43:12 +0000 Subject: [PATCH] Revert r85644. Multipart sucks because it is hard to parse and because you need to seek into the stream. I'll follow up with a solution that allows embeding data in the stream. --- includes/Export.php | 51 ++------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/includes/Export.php b/includes/Export.php index 9157f4bc7d..91eb7af375 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -35,8 +35,6 @@ class WikiExporter { var $author_list = "" ; var $dumpUploads = false; - var $multiPart = false; - var $files = array(); const FULL = 1; const CURRENT = 2; @@ -88,23 +86,12 @@ class WikiExporter { public function openStream() { $output = $this->writer->openStream(); - - if ( $this->multiPart ) { - $this->openMultipart(); - $this->sink->write( $output ); - } else { - $this->sink->writeOpenStream( $output ); - } + $this->sink->writeOpenStream( $output ); } public function closeStream() { $output = $this->writer->closeStream(); - if ( $this->multiPart ) { - $this->sink->write( $output ); - $this->closeMultipart(); - } else { - $this->sink->writeCloseStream( $output ); - } + $this->sink->writeCloseStream( $output ); } /** @@ -327,7 +314,6 @@ class WikiExporter { $output = ''; if ( $this->dumpUploads ) { $output .= $this->writer->writeUploads( $last ); - $this->attachUploads( $last ); } $output .= $this->writer->closePage(); $this->sink->writeClosePage( $output ); @@ -343,7 +329,6 @@ class WikiExporter { $output = ''; if ( $this->dumpUploads ) { $output .= $this->writer->writeUploads( $last ); - $this->attachUploads( $last ); } $output .= $this->author_list; $output .= $this->writer->closePage(); @@ -357,38 +342,6 @@ class WikiExporter { $this->sink->writeLogItem( $row, $output ); } } - - protected function attachUploads( $row ) { - $title = Title::newFromRow( $row ); - $file = wfLocalFile( $title ); - $this->files[] = $file; - $this->files = array_merge( $this->files, $file->getHistory() ); - } - - protected function openMultipart() { - # Multipart boundary purposely invalid XML - $this->boundary = '<' . dechex( mt_rand() ) . dechex( mt_rand() ) . '<'; - $this->sink->writeOpenStream( - "Content-Type: multipart/related; boundary={$this->boundary};" . - " type=text/xml\n\n" . - "--{$this->boundary}\nContent-Type: text/xml\n\n" - ); - } - - protected function closeMultipart() { - $output = ''; - - foreach ( $this->files as $file ) { - $output .= "\n--{$this->boundary}\n" . - 'Content-Type: ' . $file->getMimeType() . "\n" . - 'Content-ID: ' . $file->getRel() . "\n" . - 'Content-Length: ' . $file->getSize() . "\n" . - 'X-Sha1Base36: ' . $file->getSha1() . "\n\n"; - $this->sink->write( $output ); - $this->sink->write( file_get_contents( $file->getPath() ) ); - } - $this->sink->writeCloseStream( "\n--{$this->boundary}\n" ); - } } /** -- 2.20.1