r112744 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112743‎ | r112744 | r112745 >
Date:00:00, 1 March 2012
Author:tstarling
Status:ok
Tags:
Comment:
Fix for OOM issue observed from within this Http::get() on Wikimedia. Committing for test on server.
Modified paths:
  • /trunk/extensions/Collection/Collection.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.body.php
@@ -28,6 +28,7 @@
2929 'posturl' => 'http://pediapress.com/api/collections/',
3030 ),
3131 );
 32+ var $tempfile;
3233
3334 public function __construct() {
3435 parent::__construct( "Book" );
@@ -1076,7 +1077,7 @@
10771078 function download() {
10781079 global $wgOut, $wgRequest, $wgCollectionContentTypeToFilename;
10791080
1080 - $tempfile = tmpfile();
 1081+ $this->tempfile = tmpfile();
10811082 $r = self::mwServeCommand( 'render_status', array(
10821083 'collection_id' => $wgRequest->getVal( 'collection_id' ),
10831084 'writer' => $wgRequest->getVal( 'writer' ),
@@ -1084,9 +1085,9 @@
10851086
10861087 $info = false;
10871088 if ( isset( $r['url'] ) ) {
1088 - $result = Http::get( $r['url'] );
1089 - if ($result) {
1090 - fwrite($tempfile, $result);
 1089+ $req = MWHttpRequest::factory( $r['url'] );
 1090+ $req->setCallback( array( $this, 'writeToTempFile' ) );
 1091+ if ( $req->execute()->isOK() ) {
10911092 $info = true;
10921093 }
10931094 $content_type = $r['content_type'];
@@ -1117,11 +1118,15 @@
11181119 header( 'Content-Disposition: ' . 'inline; filename=' . $wgCollectionContentTypeToFilename[$ct] );
11191120 }
11201121 }
1121 - fseek( $tempfile, 0 );
1122 - fpassthru( $tempfile );
 1122+ fseek( $this->tempfile, 0 );
 1123+ fpassthru( $this->tempfile );
11231124 $wgOut->disable();
11241125 }
11251126
 1127+ function writeToTempFile( $res, $content ) {
 1128+ return fwrite( $this->tempfile, $content );
 1129+ }
 1130+
11261131 /**
11271132 * @param $title Title
11281133 * @param $oldid

Follow-up revisions

RevisionCommit summaryAuthorDate
r112745MFT r112744 -- fix for OOM in Http::get()tstarling00:04, 1 March 2012

Status & tagging log