https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112745

Revision: 112745
Author:   tstarling
Date:     2012-03-01 00:04:22 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
MFT r112744 -- fix for OOM in Http::get()

Modified Paths:
--------------
    branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php

Property Changed:
----------------
    branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php

Modified: branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php     
2012-03-01 00:00:44 UTC (rev 112744)
+++ branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php     
2012-03-01 00:04:22 UTC (rev 112745)
@@ -28,6 +28,7 @@
                        'posturl' => 'http://pediapress.com/api/collections/',
                ),
        );
+       var $tempfile;
 
        public function __construct() {
                parent::__construct( "Book" );
@@ -1076,7 +1077,7 @@
        function download() {
                global $wgOut, $wgRequest, $wgCollectionContentTypeToFilename;
 
-               $tempfile = tmpfile();
+               $this->tempfile = tmpfile();
                $r = self::mwServeCommand( 'render_status', array(
                        'collection_id' => $wgRequest->getVal( 'collection_id' 
),
                        'writer' => $wgRequest->getVal( 'writer' ),
@@ -1084,9 +1085,9 @@
 
                $info = false;
                if ( isset( $r['url'] ) ) {
-                       $result = Http::get( $r['url'] );
-                       if ($result) {
-                               fwrite($tempfile, $result);
+                       $req = MWHttpRequest::factory( $r['url'] );
+                       $req->setCallback( array( $this, 'writeToTempFile' ) );
+                       if ( $req->execute()->isOK() ) {
                                $info = true;
                        }
                        $content_type = $r['content_type'];
@@ -1117,11 +1118,15 @@
                                header( 'Content-Disposition: ' . 'inline; 
filename=' . $wgCollectionContentTypeToFilename[$ct] );
                        }
                }
-               fseek( $tempfile, 0 );
-               fpassthru( $tempfile );
+               fseek( $this->tempfile, 0 );
+               fpassthru( $this->tempfile );
                $wgOut->disable();
        }
 
+       function writeToTempFile( $res, $content ) {
+               return fwrite( $this->tempfile, $content );
+       }
+
        /**
         * @param $title Title
         * @param $oldid


Property changes on: 
branches/wmf/1.19wmf1/extensions/Collection/Collection.body.php
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/JSTesting/extensions/Collection/Collection.body.php:100352-107913
/branches/REL1_15/phase3/extensions/Collection/Collection.body.php:51646
/branches/REL1_17/phase3/extensions/Collection/Collection.body.php:81445,81448
/branches/new-installer/phase3/extensions/Collection/Collection.body.php:43664-66004
/branches/sqlite/extensions/Collection/Collection.body.php:58211-58321
/branches/wmf/1.18wmf1/extensions/Collection/Collection.body.php:97508
/trunk/extensions/Collection/Collection.body.php:111043,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
/trunk/phase3/extensions/Collection/Collection.body.php:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to