r85722 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85721‎ | r85722 | r85723 >
Date:14:43, 9 April 2011
Author:btongminh
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/Export.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Export.php
@@ -35,8 +35,6 @@
3636 var $author_list = "" ;
3737
3838 var $dumpUploads = false;
39 - var $multiPart = false;
40 - var $files = array();
4139
4240 const FULL = 1;
4341 const CURRENT = 2;
@@ -88,23 +86,12 @@
8987
9088 public function openStream() {
9189 $output = $this->writer->openStream();
92 -
93 - if ( $this->multiPart ) {
94 - $this->openMultipart();
95 - $this->sink->write( $output );
96 - } else {
97 - $this->sink->writeOpenStream( $output );
98 - }
 90+ $this->sink->writeOpenStream( $output );
9991 }
10092
10193 public function closeStream() {
10294 $output = $this->writer->closeStream();
103 - if ( $this->multiPart ) {
104 - $this->sink->write( $output );
105 - $this->closeMultipart();
106 - } else {
107 - $this->sink->writeCloseStream( $output );
108 - }
 95+ $this->sink->writeCloseStream( $output );
10996 }
11097
11198 /**
@@ -327,7 +314,6 @@
328315 $output = '';
329316 if ( $this->dumpUploads ) {
330317 $output .= $this->writer->writeUploads( $last );
331 - $this->attachUploads( $last );
332318 }
333319 $output .= $this->writer->closePage();
334320 $this->sink->writeClosePage( $output );
@@ -343,7 +329,6 @@
344330 $output = '';
345331 if ( $this->dumpUploads ) {
346332 $output .= $this->writer->writeUploads( $last );
347 - $this->attachUploads( $last );
348333 }
349334 $output .= $this->author_list;
350335 $output .= $this->writer->closePage();
@@ -357,38 +342,6 @@
358343 $this->sink->writeLogItem( $row, $output );
359344 }
360345 }
361 -
362 - protected function attachUploads( $row ) {
363 - $title = Title::newFromRow( $row );
364 - $file = wfLocalFile( $title );
365 - $this->files[] = $file;
366 - $this->files = array_merge( $this->files, $file->getHistory() );
367 - }
368 -
369 - protected function openMultipart() {
370 - # Multipart boundary purposely invalid XML
371 - $this->boundary = '<' . dechex( mt_rand() ) . dechex( mt_rand() ) . '<';
372 - $this->sink->writeOpenStream(
373 - "Content-Type: multipart/related; boundary={$this->boundary};" .
374 - " type=text/xml\n\n" .
375 - "--{$this->boundary}\nContent-Type: text/xml\n\n"
376 - );
377 - }
378 -
379 - protected function closeMultipart() {
380 - $output = '';
381 -
382 - foreach ( $this->files as $file ) {
383 - $output .= "\n--{$this->boundary}\n" .
384 - 'Content-Type: ' . $file->getMimeType() . "\n" .
385 - 'Content-ID: ' . $file->getRel() . "\n" .
386 - 'Content-Length: ' . $file->getSize() . "\n" .
387 - 'X-Sha1Base36: ' . $file->getSha1() . "\n\n";
388 - $this->sink->write( $output );
389 - $this->sink->write( file_get_contents( $file->getPath() ) );
390 - }
391 - $this->sink->writeCloseStream( "\n--{$this->boundary}\n" );
392 - }
393346 }
394347
395348 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85644Second part of bug bug 22881: Allow exporting files along with the XML as mim...btongminh21:44, 7 April 2011

Status & tagging log