r112745 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112744‎ | r112745 | r112746 >
Date:00:04, 1 March 2012
Author:tstarling
Status:ok
Tags:
Comment:
MFT r112744 -- fix for OOM in Http::get()
Modified paths:
  • /branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/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
Property changes on: branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php
___________________________________________________________________
Added: svn:mergeinfo
11291134 Merged /branches/new-installer/phase3/extensions/Collection/Collection.body.php:r43664-66004
11301135 Merged /branches/JSTesting/extensions/Collection/Collection.body.php:r100352-107913
11311136 Merged /branches/REL1_15/phase3/extensions/Collection/Collection.body.php:r51646
11321137 Merged /branches/wmf/1.18wmf1/extensions/Collection/Collection.body.php:r97508
11331138 Merged /branches/REL1_17/phase3/extensions/Collection/Collection.body.php:r81445,81448
11341139 Merged /trunk/extensions/Collection/Collection.body.php:r111043,111199,111218,111484,111575,111604,111659-111661,111668,111670,111688,111690,111698,111713,111715,111780,111796,111814,111947,112074,112153,112160,112166,112260,112282,112360,112517,112571,112613,112628,112739-112740,112744
11351140 Merged /branches/sqlite/extensions/Collection/Collection.body.php:r58211-58321
11361141 Merged /trunk/phase3/extensions/Collection/Collection.body.php:r111002,111029,111034,111062,111067,111076,111085,111128,111144,111251

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112744Fix for OOM issue observed from within this Http::get() on Wikimedia. Committ...tstarling00:00, 1 March 2012

Status & tagging log