r63621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63620‎ | r63621 | r63622 >
Date:00:02, 12 March 2010
Author:mah
Status:ok
Tags:
Comment:
Rollback chunked uploading support for 1.16
Modified paths:
  • /branches/REL1_16/phase3/includes/AutoLoader.php (modified) (history)
  • /branches/REL1_16/phase3/includes/api/ApiBase.php (modified) (history)
  • /branches/REL1_16/phase3/includes/api/ApiUpload.php (modified) (history)
  • /branches/REL1_16/phase3/includes/upload/UploadFromChunks.php (deleted) (history)
  • /branches/REL1_16/phase3/maintenance/tests/UploadFromChunksTest.php (deleted) (history)

Diff [purge]

Index: branches/REL1_16/phase3/maintenance/tests/UploadFromChunksTest.php
@@ -1,318 +0,0 @@
2 -<?php
3 -
4 -require_once( "ApiSetup.php" );
5 -
6 -class UploadFromChunksTest extends ApiSetup {
7 -
8 - function setUp() {
9 - global $wgEnableUploads;
10 -
11 - $wgEnableUploads = true;
12 - parent::setup();
13 -
14 - ini_set( 'file_loads', 1 );
15 - ini_set( 'log_errors', 1 );
16 - ini_set( 'error_reporting', 1 );
17 - ini_set( 'display_errors', 1 );
18 - }
19 -
20 - function makeChunk( $content ) {
21 - $file = tempnam( wfTempDir(), "" );
22 - $fh = fopen( $file, "w" );
23 - if ( $fh == false ) {
24 - $this->markTestIncomplete( "Couldn't open $file!\n" );
25 - return;
26 - }
27 - fwrite( $fh, $content );
28 - fclose( $fh );
29 -
30 - $_FILES['chunk']['tmp_name'] = $file;
31 - $_FILES['chunk']['size'] = 3;
32 - $_FILES['chunk']['error'] = null;
33 - $_FILES['chunk']['name'] = "test.txt";
34 - }
35 -
36 - function cleanChunk() {
37 - if ( file_exists( $_FILES['chunk']['tmp_name'] ) )
38 - unlink( $_FILES['chunk']['tmp_name'] );
39 - }
40 -
41 - function doApiRequest( $params, $data = null ) {
42 - $session = isset( $data[2] ) ? $data[2] : array();
43 - $_SESSION = $session;
44 -
45 - $req = new FauxRequest( $params, true, $session );
46 - $module = new ApiMain( $req, true );
47 - $module->execute();
48 -
49 - return array( $module->getResultData(), $req, $_SESSION );
50 - }
51 -
52 - function testGetTitle() {
53 - $filename = tempnam( wfTempDir(), "" );
54 - $c = new UploadFromChunks();
55 - $c->initialize( false, "temp.txt", null, $filename, 0, null );
56 - $this->assertEquals( null, $c->getTitle() );
57 -
58 - $c = new UploadFromChunks();
59 - $c->initialize( false, "temp.png", null, $filename, 0, null );
60 - $this->assertEquals( Title::makeTitleSafe( NS_FILE, "Temp.png" ), $c->getTitle() );
61 - }
62 -
63 - function testLogin() {
64 - $data = $this->doApiRequest( array(
65 - 'action' => 'login',
66 - 'lgname' => self::$userName,
67 - 'lgpassword' => self::$passWord ) );
68 - $this->assertArrayHasKey( "login", $data[0] );
69 - $this->assertArrayHasKey( "result", $data[0]['login'] );
70 - $this->assertEquals( "Success", $data[0]['login']['result'] );
71 - $this->assertArrayHasKey( 'lgtoken', $data[0]['login'] );
72 -
73 - return $data;
74 - }
75 -
76 - /**
77 - * @depends testLogin
78 - */
79 - function testSetupChunkSession( $data ) {
80 - global $wgUser;
81 - $wgUser = User::newFromName( self::$userName );
82 - $wgUser->load();
83 - $data[2]['wsEditToken'] = $data[2]['wsToken'];
84 - $token = md5( $data[2]['wsToken'] ) . EDIT_TOKEN_SUFFIX;
85 - $exception = false;
86 -
87 - $data = $this->doApiRequest( array(
88 - 'filename' => 'tmp.txt',
89 - 'action' => 'upload',
90 - 'enablechunks' => true,
91 - 'token' => $token ), $data );
92 - $this->assertArrayHasKey( 'uploadUrl', $data[0] );
93 - $this->assertRegexp( '/action=upload/', $data[0]['uploadUrl'] );
94 - $this->assertRegexp( '/enablechunks=true/', $data[0]['uploadUrl'] );
95 - $this->assertRegexp( '/format=json/', $data[0]['uploadUrl'] );
96 - $this->assertRegexp( '/chunksession=/', $data[0]['uploadUrl'] );
97 - $this->assertRegexp( '/token=/', $data[0]['uploadUrl'] );
98 -
99 - return $data;
100 - }
101 -
102 - /**
103 - * @depends testSetupChunkSession
104 - */
105 - function testAppendChunkTypeBanned( $data ) {
106 - global $wgUser;
107 - $wgUser = User::newFromName( self::$userName );
108 -
109 - $url = $data[0]['uploadUrl'];
110 - $params = wfCgiToArray( substr( $url, strpos( $url, "?" ) ) );
111 -
112 - $size = 0;
113 - for ( $i = 0; $i < 4; $i++ ) {
114 - $this->makeChunk( "123" );
115 - $size += $_FILES['chunk']['size'];
116 -
117 - $data = $this->doApiRequest( $params, $data );
118 - $this->assertArrayHasKey( "result", $data[0] );
119 - $this->assertTrue( (bool)$data[0]["result"] );
120 -
121 - $this->assertArrayHasKey( "filesize", $data[0] );
122 - $this->assertEquals( $size, $data[0]['filesize'] );
123 -
124 - $this->cleanChunk();
125 - }
126 -
127 - $data['param'] = $params;
128 - return $data;
129 - }
130 -
131 - /**
132 - * @depends testLogin
133 - */
134 - function testInvalidSessionKey( $data ) {
135 - global $wgUser;
136 - $wgUser = User::newFromName( self::$userName );
137 - $wgUser->load();
138 - $data[2]['wsEditToken'] = $data[2]['wsToken'];
139 - $token = md5( $data[2]['wsToken'] ) . EDIT_TOKEN_SUFFIX;
140 - $exception = false;
141 -
142 - try {
143 - $this->doApiRequest( array(
144 - 'action' => 'upload',
145 - 'enablechunks' => true,
146 - 'token' => $token,
147 - 'chunksession' => 'bogus' ), $data );
148 - } catch ( UsageException $e ) {
149 - $exception = true;
150 - $this->assertEquals( "Not a valid session key", $e->getMessage() );
151 - }
152 -
153 - $this->assertTrue( $exception, "Got exception" );
154 - }
155 -
156 - function testPerformUploadInitError() {
157 - global $wgUser;
158 - $wgUser = User::newFromId( 1 );
159 -
160 - $req = new FauxRequest(
161 - array(
162 - 'action' => 'upload',
163 - 'enablechunks' => 'false',
164 - 'sessionkey' => '1',
165 - 'filename' => 'test.png',
166 - ) );
167 - $module = new ApiMain( $req, true );
168 - $gotException = false;
169 - try {
170 - $module->execute();
171 - } catch ( UsageException $e ) {
172 - $this->assertEquals( "The token parameter must be set", $e->getMessage() );
173 - $gotException = true;
174 - }
175 -
176 - $this->assertTrue( $gotException );
177 - }
178 -
179 - /**
180 - * @depends testAppendChunkTypeBanned
181 - */
182 - function testUploadChunkDoneTypeBanned( $data ) {
183 - global $wgUser;
184 - $wgUser = User::newFromName( self::$userName );
185 - $token = $wgUser->editToken();
186 - $params = $data['param'];
187 - $params['done'] = 1;
188 -
189 - $this->makeChunk( "123" );
190 -
191 - $gotException = false;
192 - try {
193 - $data = $this->doApiRequest( $params, $data );
194 - } catch ( UsageException $e ) {
195 - $this->assertEquals( "This type of file is banned",
196 - $e->getMessage() );
197 - $gotException = true;
198 - }
199 - $this->cleanChunk();
200 - $this->assertTrue( $gotException );
201 - }
202 -
203 - /**
204 - * @depends testLogin
205 - */
206 - function testUploadChunkDoneDuplicate( $data ) {
207 - global $wgUser, $wgVerifyMimeType;
208 -
209 - $wgVerifyMimeType = false;
210 - $wgUser = User::newFromName( self::$userName );
211 - $data[2]['wsEditToken'] = $data[2]['wsToken'];
212 - $token = md5( $data[2]['wsToken'] ) . EDIT_TOKEN_SUFFIX;
213 - $data = $this->doApiRequest( array(
214 - 'filename' => 'tmp.png',
215 - 'action' => 'upload',
216 - 'enablechunks' => true,
217 - 'token' => $token ), $data );
218 -
219 - $url = $data[0]['uploadUrl'];
220 - $params = wfCgiToArray( substr( $url, strpos( $url, "?" ) ) );
221 - $size = 0;
222 - for ( $i = 0; $i < 4; $i++ ) {
223 - $this->makeChunk( "123" );
224 - $size += $_FILES['chunk']['size'];
225 -
226 - $data = $this->doApiRequest( $params, $data );
227 - $this->assertArrayHasKey( "result", $data[0] );
228 - $this->assertTrue( (bool)$data[0]["result"] );
229 -
230 - $this->assertArrayHasKey( "filesize", $data[0] );
231 - $this->assertEquals( $size, $data[0]['filesize'] );
232 -
233 - $this->cleanChunk();
234 - }
235 -
236 - $params['done'] = true;
237 -
238 - $this->makeChunk( "123" );
239 - $data = $this->doApiRequest( $params, $data );
240 - $this->cleanChunk();
241 -
242 - $this->assertArrayHasKey( 'upload', $data[0] );
243 - $this->assertArrayHasKey( 'result', $data[0]['upload'] );
244 - $this->assertEquals( 'Warning', $data[0]['upload']['result'] );
245 -
246 - $this->assertArrayHasKey( 'warnings', $data[0]['upload'] );
247 - $this->assertArrayHasKey( 'exists',
248 - $data[0]['upload']['warnings'] );
249 - $this->assertEquals( 'Tmp.png',
250 - $data[0]['upload']['warnings']['exists'] );
251 -
252 - }
253 -
254 - /**
255 - * @depends testLogin
256 - */
257 - function testUploadChunkDoneGood( $data ) {
258 - global $wgUser, $wgVerifyMimeType;
259 - $wgVerifyMimeType = false;
260 -
261 - $id = Title::newFromText( "Twar.png", NS_FILE )->getArticleID();
262 -
263 - $oldFile = Article::newFromID( $id );
264 - if ( $oldFile ) {
265 - $oldFile->doDeleteArticle();
266 - $oldFile->doPurge();
267 - }
268 - $oldFile = wfFindFile( "Twar.png" );
269 - if ( $oldFile ) {
270 - $oldFile->delete();
271 - }
272 -
273 - $wgUser = User::newFromName( self::$userName );
274 - $data[2]['wsEditToken'] = $data[2]['wsToken'];
275 - $token = md5( $data[2]['wsToken'] ) . EDIT_TOKEN_SUFFIX;
276 - $data = $this->doApiRequest( array(
277 - 'filename' => 'twar.png',
278 - 'action' => 'upload',
279 - 'enablechunks' => true,
280 - 'token' => $token ), $data );
281 -
282 - $url = $data[0]['uploadUrl'];
283 - $params = wfCgiToArray( substr( $url, strpos( $url, "?" ) ) );
284 - $size = 0;
285 - for ( $i = 0; $i < 5; $i++ ) {
286 - $this->makeChunk( "123" );
287 - $size += $_FILES['chunk']['size'];
288 -
289 - $data = $this->doApiRequest( $params, $data );
290 - $this->assertArrayHasKey( "result", $data[0] );
291 - $this->assertTrue( (bool)$data[0]["result"] );
292 -
293 - $this->assertArrayHasKey( "filesize", $data[0] );
294 - $this->assertEquals( $size, $data[0]['filesize'] );
295 -
296 - $this->cleanChunk();
297 - }
298 -
299 - $params['done'] = true;
300 -
301 - $this->makeChunk( "456" );
302 - $data = $this->doApiRequest( $params, $data );
303 -
304 - $this->cleanChunk();
305 -
306 - if ( isset( $data[0]['upload'] ) ) {
307 - $this->markTestSkipped( "Please run 'php maintenance/deleteArchivedFiles.php --delete --force' and 'php maintenance/deleteArchivedRevisions.php --delete'" );
308 - }
309 -
310 - $this->assertArrayHasKey( 'result', $data[0] );
311 - $this->assertEquals( 1, $data[0]['result'] );
312 -
313 - $this->assertArrayHasKey( 'done', $data[0] );
314 - $this->assertEquals( 1, $data[0]['done'] );
315 -
316 - $this->assertArrayHasKey( 'resultUrl', $data[0] );
317 - $this->assertRegExp( '/File:Twar.png/', $data[0]['resultUrl'] );
318 - }
319 -}
Index: branches/REL1_16/phase3/includes/upload/UploadFromChunks.php
@@ -1,254 +0,0 @@
2 -<?php
3 -/**
4 - * @file
5 - * @ingroup upload
6 - *
7 - * First, destination checks are made, and, if ignorewarnings is not
8 - * checked, errors / warning is returned.
9 - *
10 - * 1. We return the uploadUrl.
11 - * 2. We then accept chunk uploads from the client.
12 - * 3. Return chunk id on each POSTED chunk.
13 - * 4. Once the client posts "done=1", the files are concatenated together.
14 - *
15 - * (More info at: http://firefogg.org/dev/chunk_post.html)
16 - */
17 -class UploadFromChunks extends UploadBase {
18 -
19 - const INIT = 1;
20 - const CHUNK = 2;
21 - const DONE = 3;
22 -
23 - protected $chunkMode; // INIT, CHUNK, DONE
24 - protected $sessionKey;
25 - protected $comment;
26 - protected $repoPath;
27 - protected $pageText;
28 - protected $watch;
29 -
30 - public $status;
31 -
32 - // Parent class requires this function even though it is only
33 - // used from SpecialUpload.php and we don't do chunked uploading
34 - // from SpecialUpload -- best to raise an exception for
35 - // now.
36 - public function initializeFromRequest( &$request ) {
37 - throw new MWException( 'not implemented' );
38 - }
39 -
40 - public function initialize( $done, $filename, $sessionKey, $path, $fileSize, $sessionData ) {
41 - $this->status = Status::newGood();
42 -
43 - $this->initializePathInfo( $filename, $path, 0, true );
44 - if ( $sessionKey !== null ) {
45 - $this->initFromSessionKey( $sessionKey, $sessionData, $fileSize );
46 -
47 - if ( $done ) {
48 - $this->chunkMode = self::DONE;
49 - } else {
50 - $this->mTempPath = $path;
51 - $this->chunkMode = self::CHUNK;
52 - }
53 - } else {
54 - // session key not set, init the chunk upload system:
55 - $this->chunkMode = self::INIT;
56 - }
57 -
58 - if ( $this->status->isOk()
59 - && ( $this->mDesiredDestName === null || $this->mFileSize === null ) ) {
60 - $this->status = Status::newFatal( 'chunk-init-error' );
61 - }
62 - }
63 -
64 - /**
65 - * Set session information for chunked uploads and allocate a unique key.
66 - * @param $comment string
67 - * @param $pageText string
68 - * @param $watch boolean
69 - *
70 - * @returns string the session key for this chunked upload
71 - */
72 - protected function setupChunkSession( $comment, $pageText, $watch ) {
73 - if ( !isset( $this->sessionKey ) ) {
74 - $this->sessionKey = $this->getSessionKey();
75 - }
76 - foreach ( array( 'mFilteredName', 'repoPath', 'mFileSize', 'mDesiredDestName' )
77 - as $key ) {
78 - if ( isset( $this->$key ) ) {
79 - $_SESSION['wsUploadData'][$this->sessionKey][$key] = $this->$key;
80 - }
81 - }
82 - if ( isset( $comment ) ) {
83 - $_SESSION['wsUploadData'][$this->sessionKey]['commment'] = $comment;
84 - }
85 - if ( isset( $pageText ) ) {
86 - $_SESSION['wsUploadData'][$this->sessionKey]['pageText'] = $pageText;
87 - }
88 - if ( isset( $watch ) ) {
89 - $_SESSION['wsUploadData'][$this->sessionKey]['watch'] = $watch;
90 - }
91 - $_SESSION['wsUploadData'][$this->sessionKey]['version'] = self::SESSION_VERSION;
92 -
93 - return $this->sessionKey;
94 - }
95 -
96 - /**
97 - * Initialize a continuation of a chunked upload from a session key
98 - * @param $sessionKey string
99 - * @param $request WebRequest
100 - * @param $fileSize int Size of this chunk
101 - *
102 - * @returns void
103 - */
104 - protected function initFromSessionKey( $sessionKey, $sessionData, $fileSize ) {
105 - // testing against null because we don't want to cause obscure
106 - // bugs when $sessionKey is full of "0"
107 - $this->sessionKey = $sessionKey;
108 -
109 - if ( isset( $sessionData[$this->sessionKey]['version'] )
110 - && $sessionData[$this->sessionKey]['version'] == self::SESSION_VERSION )
111 - {
112 - foreach ( array( 'comment', 'pageText', 'watch', 'mFilteredName', 'repoPath', 'mFileSize', 'mDesiredDestName' )
113 - as $key ) {
114 - if ( isset( $sessionData[$this->sessionKey][$key] ) ) {
115 - $this->$key = $sessionData[$this->sessionKey][$key];
116 - }
117 - }
118 -
119 - $this->mFileSize += $fileSize;
120 - } else {
121 - $this->status = Status::newFatal( 'invalid-session-key' );
122 - }
123 - }
124 -
125 - /**
126 - * Handle a chunk of the upload. Overrides the parent method
127 - * because Chunked Uploading clients (i.e. Firefogg) require
128 - * specific API responses.
129 - * @see UploadBase::performUpload
130 - */
131 - public function performUpload( $comment, $pageText, $watch, $user ) {
132 - wfDebug( "\n\n\performUpload(chunked): comment:" . $comment . ' pageText: ' . $pageText . ' watch:' . $watch );
133 - global $wgUser, $wgOut;
134 -
135 - if ( $this->chunkMode == self::INIT ) {
136 - // firefogg expects a specific result per:
137 - // http://www.firefogg.org/dev/chunk_post.html
138 -
139 - // it's okay to return the token here because
140 - // a) the user must have requested the token to get here and
141 - // b) should only happen over POST
142 - // c) we need the token to validate chunks are coming from a non-xss request
143 - return Status::newGood(
144 - array( 'uploadUrl' => wfExpandUrl( wfScript( 'api' ) ) . "?" .
145 - wfArrayToCGI( array(
146 - 'action' => 'upload',
147 - 'token' => $wgUser->editToken(),
148 - 'format' => 'json',
149 - 'filename' => $this->mDesiredDestName,
150 - 'enablechunks' => 'true',
151 - 'chunksession' =>
152 - $this->setupChunkSession( $comment, $pageText, $watch ) ) ) ) );
153 - } else if ( $this->chunkMode == self::CHUNK ) {
154 - $this->setupChunkSession();
155 - $this->appendChunk();
156 - if ( !$this->status->isOK() ) {
157 - return $this->status;
158 - }
159 - // return success:
160 - // firefogg expects a specific result
161 - // http://www.firefogg.org/dev/chunk_post.html
162 - return Status::newGood(
163 - array( 'result' => 1, 'filesize' => $this->mFileSize )
164 - );
165 - } else if ( $this->chunkMode == self::DONE ) {
166 - $this->finalizeFile();
167 - // We ignore the passed-in parameters because these were set on the first contact.
168 - $status = parent::performUpload( $this->comment, $this->pageText, $this->watch, $user );
169 -
170 - if ( !$status->isGood() ) {
171 - return $status;
172 - }
173 - $file = $this->getLocalFile();
174 -
175 - // firefogg expects a specific result
176 - // http://www.firefogg.org/dev/chunk_post.html
177 - return Status::newGood(
178 - array( 'result' => 1, 'done' => 1, 'resultUrl' => wfExpandUrl( $file->getDescriptionUrl() ) )
179 - );
180 - }
181 -
182 - return Status::newGood();
183 - }
184 -
185 - /**
186 - * Append a chunk to the Repo file
187 - *
188 - * @param string $srcPath Path to file to append from
189 - * @param string $toAppendPath Path to file to append to
190 - * @return Status Status
191 - */
192 - protected function appendToUploadFile( $srcPath, $toAppendPath ) {
193 - $repo = RepoGroup::singleton()->getLocalRepo();
194 - $status = $repo->append( $srcPath, $toAppendPath );
195 - return $status;
196 - }
197 -
198 - /**
199 - * Append a chunk to the temporary file.
200 - *
201 - * @return void
202 - */
203 - protected function appendChunk() {
204 - global $wgMaxUploadSize;
205 -
206 - if ( !$this->repoPath ) {
207 - $this->status = $this->saveTempUploadedFile( $this->mDesiredDestName, $this->mTempPath );
208 -
209 - if ( $this->status->isOK() ) {
210 - $this->repoPath = $this->status->value;
211 - $_SESSION['wsUploadData'][$this->sessionKey]['repoPath'] = $this->repoPath;
212 - }
213 - return;
214 - }
215 - if ( $this->getRealPath( $this->repoPath ) ) {
216 - $this->status = $this->appendToUploadFile( $this->repoPath, $this->mTempPath );
217 -
218 - if ( $this->mFileSize > $wgMaxUploadSize )
219 - $this->status = Status::newFatal( 'largefileserver' );
220 -
221 - } else {
222 - $this->status = Status::newFatal( 'filenotfound', $this->repoPath );
223 - }
224 - }
225 -
226 - /**
227 - * Append the final chunk and ready file for parent::performUpload()
228 - * @return void
229 - */
230 - protected function finalizeFile() {
231 - $this->appendChunk();
232 - $this->mTempPath = $this->getRealPath( $this->repoPath );
233 - }
234 -
235 - public function verifyUpload() {
236 - if ( $this->chunkMode != self::DONE ) {
237 - return array( 'status' => UploadBase::OK );
238 - }
239 - return parent::verifyUpload();
240 - }
241 -
242 - public function checkWarnings() {
243 - if ( $this->chunkMode != self::DONE ) {
244 - return null;
245 - }
246 - return parent::checkWarnings();
247 - }
248 -
249 - public function getImageInfo( $result ) {
250 - if ( $this->chunkMode != self::DONE ) {
251 - return null;
252 - }
253 - return parent::getImageInfo( $result );
254 - }
255 -}
Index: branches/REL1_16/phase3/includes/api/ApiBase.php
@@ -920,8 +920,6 @@
921921 'invalid-session-key' => array( 'code' => 'invalid-session-key', 'info' => 'Not a valid session key' ),
922922 'nouploadmodule' => array( 'code' => 'nouploadmodule', 'info' => 'No upload module set' ),
923923 'uploaddisabled' => array( 'code' => 'uploaddisabled', 'info' => 'Uploads are not enabled. Make sure $wgEnableUploads is set to true in LocalSettings.php and the PHP ini setting file_uploads is true' ),
924 - 'chunked-error' => array( 'code' => 'chunked-error', 'info' => 'There was a problem initializing the chunked upload.' ),
925 - 'chunk-init-error' => array( 'code' => 'chunk-init-error', 'info' => 'Insufficient information for initialization.' ),
926924 );
927925
928926 /**
Index: branches/REL1_16/phase3/includes/api/ApiUpload.php
@@ -52,25 +52,9 @@
5353
5454 // One and only one of the following parameters is needed
5555 $this->requireOnlyOneParameter( $this->mParams,
56 - 'sessionkey', 'file', 'url', 'enablechunks' );
 56+ 'sessionkey', 'file', 'url' );
5757
58 - // Initialize $this->mUpload
59 - if ( $this->mParams['enablechunks'] ) {
60 - $this->mUpload = new UploadFromChunks();
61 -
62 - $this->mUpload->initialize(
63 - $request->getVal( 'done', null ),
64 - $request->getVal( 'filename', null ),
65 - $request->getVal( 'chunksession', null ),
66 - $request->getFileTempName( 'chunk' ),
67 - $request->getFileSize( 'chunk' ),
68 - $request->getSessionData( 'wsUploadData' )
69 - );
70 -
71 - if ( !$this->mUpload->status->isOK() ) {
72 - $this->dieUsageMsg( $this->mUpload->status->getErrorsArray() );
73 - }
74 - } elseif ( $this->mParams['sessionkey'] ) {
 58+ if ( $this->mParams['sessionkey'] ) {
7559 /**
7660 * Upload stashed in a previous request
7761 */
@@ -132,14 +116,7 @@
133117 // Cleanup any temporary mess
134118 $this->mUpload->cleanupTempFile();
135119
136 - if ( isset( $result['chunked-output'] ) ) {
137 - foreach ( $result['chunked-output'] as $key => $value ) {
138 - if ( $value === null ) $value = "";
139 - $this->getResult()->addValue( null, $key, $value );
140 - }
141 - } else {
142 - $this->getResult()->addValue( null, $this->getModuleName(), $result );
143 - }
 120+ $this->getResult()->addValue( null, $this->getModuleName(), $result );
144121 }
145122
146123 protected function performUpload() {
@@ -242,8 +219,6 @@
243220 $this->getResult()->setIndexedTagName( $result['details'], 'error' );
244221
245222 $this->dieUsage( 'An internal error occurred', 'internal-error', 0, $error );
246 - } elseif ( $this->mParams['enablechunks'] ) {
247 - return array( "chunked-output" => $status->value );
248223 }
249224
250225 $file = $this->mUpload->getLocalFile();
@@ -273,10 +248,6 @@
274249 'watch' => false,
275250 'ignorewarnings' => false,
276251 'file' => null,
277 - 'enablechunks' => false,
278 - 'chunksession' => null,
279 - 'chunk' => null,
280 - 'done' => false,
281252 'url' => null,
282253 'sessionkey' => null,
283254 );
@@ -296,10 +267,6 @@
297268 'watch' => 'Watch the page',
298269 'ignorewarnings' => 'Ignore any warnings',
299270 'file' => 'File contents',
300 - 'enablechunks' => 'Set to use chunk mode; see http://firefogg.org/dev/chunk_post.html for protocol',
301 - 'chunksession' => 'The session key, established on the first contact during the chunked upload',
302 - 'chunk' => 'The data in this chunk of a chunked upload',
303 - 'done' => 'Set to 1 on the last chunk of a chunked upload',
304271 'url' => 'Url to fetch the file from',
305272 'sessionkey' => array(
306273 'Session key returned by a previous upload that failed due to warnings',
@@ -311,11 +278,10 @@
312279 return array(
313280 'Upload a file, or get the status of pending uploads. Several methods are available:',
314281 ' * Upload file contents directly, using the "file" parameter',
315 - ' * Upload a file in chunks, using the "enablechunks",',
316282 ' * Have the MediaWiki server fetch a file from a URL, using the "url" parameter',
317283 ' * Complete an earlier upload that failed due to warnings, using the "sessionkey" parameter',
318284 'Note that the HTTP POST must be done as a file upload (i.e. using multipart/form-data) when',
319 - 'sending the "file" or "chunk" parameters. Note also that queries using session keys must be',
 285+ 'sending the "file". Note also that queries using session keys must be',
320286 'done in the same login session as the query that originally returned the key (i.e. do not',
321287 'log out and then log back in). Also you must get and send an edit token before doing any upload stuff.'
322288 );
@@ -352,8 +318,6 @@
353319 ' api.php?action=upload&filename=Wiki.png&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png',
354320 'Complete an upload that failed due to warnings:',
355321 ' api.php?action=upload&filename=Wiki.png&sessionkey=sessionkey&ignorewarnings=1',
356 - 'Begin a chunked upload:',
357 - ' api.php?action=upload&filename=Wiki.png&enablechunks=1'
358322 );
359323 }
360324
Index: branches/REL1_16/phase3/includes/AutoLoader.php
@@ -236,7 +236,6 @@
237237 'UploadFromStash' => 'includes/upload/UploadFromStash.php',
238238 'UploadFromFile' => 'includes/upload/UploadFromFile.php',
239239 'UploadFromUrl' => 'includes/upload/UploadFromUrl.php',
240 - 'UploadFromChunks' => 'includes/upload/UploadFromChunks.php',
241240 'User' => 'includes/User.php',
242241 'UserArray' => 'includes/UserArray.php',
243242 'UserArrayFromResult' => 'includes/UserArray.php',

Follow-up revisions

RevisionCommit summaryAuthorDate
r63638Merge r63621 and r63636 from REL1_16:...btongminh18:26, 12 March 2010

Status & tagging log