Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | 'posturl' => 'http://pediapress.com/api/collections/', |
30 | 30 | ), |
31 | 31 | ); |
| 32 | + var $tempfile; |
32 | 33 | |
33 | 34 | public function __construct() { |
34 | 35 | parent::__construct( "Book" ); |
— | — | @@ -1076,7 +1077,7 @@ |
1077 | 1078 | function download() { |
1078 | 1079 | global $wgOut, $wgRequest, $wgCollectionContentTypeToFilename; |
1079 | 1080 | |
1080 | | - $tempfile = tmpfile(); |
| 1081 | + $this->tempfile = tmpfile(); |
1081 | 1082 | $r = self::mwServeCommand( 'render_status', array( |
1082 | 1083 | 'collection_id' => $wgRequest->getVal( 'collection_id' ), |
1083 | 1084 | 'writer' => $wgRequest->getVal( 'writer' ), |
— | — | @@ -1084,9 +1085,9 @@ |
1085 | 1086 | |
1086 | 1087 | $info = false; |
1087 | 1088 | 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() ) { |
1091 | 1092 | $info = true; |
1092 | 1093 | } |
1093 | 1094 | $content_type = $r['content_type']; |
— | — | @@ -1117,11 +1118,15 @@ |
1118 | 1119 | header( 'Content-Disposition: ' . 'inline; filename=' . $wgCollectionContentTypeToFilename[$ct] ); |
1119 | 1120 | } |
1120 | 1121 | } |
1121 | | - fseek( $tempfile, 0 ); |
1122 | | - fpassthru( $tempfile ); |
| 1122 | + fseek( $this->tempfile, 0 ); |
| 1123 | + fpassthru( $this->tempfile ); |
1123 | 1124 | $wgOut->disable(); |
1124 | 1125 | } |
1125 | 1126 | |
| 1127 | + function writeToTempFile( $res, $content ) { |
| 1128 | + return fwrite( $this->tempfile, $content ); |
| 1129 | + } |
| 1130 | + |
1126 | 1131 | /** |
1127 | 1132 | * @param $title Title |
1128 | 1133 | * @param $oldid |