r62177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62176‎ | r62177 | r62178 >
Date:09:41, 9 February 2010
Author:mah
Status:ok
Tags:
Comment:
follow-up r61355 a bit more, still have several bits to fix (e.g. json handling)
Modified paths:
  • /trunk/phase3/includes/upload/UploadFromChunks.php (modified) (history)
  • /trunk/phase3/maintenance/tests/UploadFromChunksTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/UploadFromChunksTest.php
@@ -11,6 +11,17 @@
1212 ini_set('file_loads', true);
1313 }
1414
 15+ function testGetTitle() {
 16+ $filename = tempnam( wfTempDir(), "" );
 17+ $c = new UploadFromChunks();
 18+ $c->initialize(false, "temp.txt", null, $filename, 0, null);
 19+ $this->assertEquals(null, $c->getTitle());
 20+
 21+ $c = new UploadFromChunks();
 22+ $c->initialize(false, "temp.png", null, $filename, 0, null);
 23+ $this->assertEquals(Title::makeTitleSafe(NS_FILE, "Temp.png"), $c->getTitle());
 24+ }
 25+
1526 function testGetEditToken() {
1627 }
1728
@@ -58,7 +69,7 @@
5970 $req = new FauxRequest(
6071 array('action' => 'upload',
6172 'enablechunks' => '1',
62 - 'filename' => 'test.txt',
 73+ 'filename' => 'test.png',
6374 'token' => $token,
6475 ));
6576 $module = new ApiMain($req, true);
@@ -75,7 +86,7 @@
7687 $req = new FauxRequest(
7788 array('action' => 'upload',
7889 'enablechunks' => '1',
79 - 'filename' => 'test.txt',
 90+ 'filename' => 'test.png',
8091 'token' => $token,
8192 ));
8293 $module = new ApiMain($req, true);
Index: trunk/phase3/includes/upload/UploadFromChunks.php
@@ -40,6 +40,8 @@
4141 public function initialize( $done, $filename, $sessionKey, $path,
4242 $fileSize, $sessionData )
4343 {
 44+ $this->status = new Status;
 45+
4446 $this->initFromSessionKey( $sessionKey, $sessionData );
4547
4648 if ( !$this->sessionKey && !$done ) {
@@ -127,7 +129,6 @@
128130 // b) should only happen over POST
129131 // c) we need the token to validate chunks are coming from a non-xss request
130132 $token = urlencode( $wgUser->editToken() );
131 - ob_clean();
132133 echo FormatJson::encode( array(
133134 'uploadUrl' => wfExpandUrl( wfScript( 'api' ) ) . "?action=upload&" .
134135 "token={$token}&format=json&enablechunks=true&chunksessionkey=" .
@@ -141,7 +142,6 @@
142143 // return success:
143144 // firefogg expects a specific result
144145 // http://www.firefogg.org/dev/chunk_post.html
145 - ob_clean();
146146 echo FormatJson::encode(
147147 array( 'result' => 1, 'filesize' => $this->fileSize )
148148 );
@@ -164,7 +164,6 @@
165165
166166 // firefogg expects a specific result
167167 // http://www.firefogg.org/dev/chunk_post.html
168 - ob_clean();
169168 echo FormatJson::encode( array(
170169 'result' => 1,
171170 'done' => 1,
@@ -172,6 +171,8 @@
173172 );
174173 $wgOut->disable();
175174 }
 175+
 176+ return Status::newGood();
176177 }
177178
178179 /**
@@ -215,7 +216,7 @@
216217
217218 public function verifyUpload() {
218219 if ( $this->chunkMode != self::DONE ) {
219 - return Status::newGood();
 220+ return array('status' => UploadBase::OK);
220221 }
221222 return parent::verifyUpload();
222223 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61355UploadChunks added from js2 branch. Refactored. Still needs to be...mah04:37, 22 January 2010

Status & tagging log