Index: trunk/phase3/maintenance/tests/UploadFromChunksTest.php |
— | — | @@ -11,6 +11,17 @@ |
12 | 12 | ini_set('file_loads', true); |
13 | 13 | } |
14 | 14 | |
| 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 | + |
15 | 26 | function testGetEditToken() { |
16 | 27 | } |
17 | 28 | |
— | — | @@ -58,7 +69,7 @@ |
59 | 70 | $req = new FauxRequest( |
60 | 71 | array('action' => 'upload', |
61 | 72 | 'enablechunks' => '1', |
62 | | - 'filename' => 'test.txt', |
| 73 | + 'filename' => 'test.png', |
63 | 74 | 'token' => $token, |
64 | 75 | )); |
65 | 76 | $module = new ApiMain($req, true); |
— | — | @@ -75,7 +86,7 @@ |
76 | 87 | $req = new FauxRequest( |
77 | 88 | array('action' => 'upload', |
78 | 89 | 'enablechunks' => '1', |
79 | | - 'filename' => 'test.txt', |
| 90 | + 'filename' => 'test.png', |
80 | 91 | 'token' => $token, |
81 | 92 | )); |
82 | 93 | $module = new ApiMain($req, true); |
Index: trunk/phase3/includes/upload/UploadFromChunks.php |
— | — | @@ -40,6 +40,8 @@ |
41 | 41 | public function initialize( $done, $filename, $sessionKey, $path, |
42 | 42 | $fileSize, $sessionData ) |
43 | 43 | { |
| 44 | + $this->status = new Status; |
| 45 | + |
44 | 46 | $this->initFromSessionKey( $sessionKey, $sessionData ); |
45 | 47 | |
46 | 48 | if ( !$this->sessionKey && !$done ) { |
— | — | @@ -127,7 +129,6 @@ |
128 | 130 | // b) should only happen over POST |
129 | 131 | // c) we need the token to validate chunks are coming from a non-xss request |
130 | 132 | $token = urlencode( $wgUser->editToken() ); |
131 | | - ob_clean(); |
132 | 133 | echo FormatJson::encode( array( |
133 | 134 | 'uploadUrl' => wfExpandUrl( wfScript( 'api' ) ) . "?action=upload&" . |
134 | 135 | "token={$token}&format=json&enablechunks=true&chunksessionkey=" . |
— | — | @@ -141,7 +142,6 @@ |
142 | 143 | // return success: |
143 | 144 | // firefogg expects a specific result |
144 | 145 | // http://www.firefogg.org/dev/chunk_post.html |
145 | | - ob_clean(); |
146 | 146 | echo FormatJson::encode( |
147 | 147 | array( 'result' => 1, 'filesize' => $this->fileSize ) |
148 | 148 | ); |
— | — | @@ -164,7 +164,6 @@ |
165 | 165 | |
166 | 166 | // firefogg expects a specific result |
167 | 167 | // http://www.firefogg.org/dev/chunk_post.html |
168 | | - ob_clean(); |
169 | 168 | echo FormatJson::encode( array( |
170 | 169 | 'result' => 1, |
171 | 170 | 'done' => 1, |
— | — | @@ -172,6 +171,8 @@ |
173 | 172 | ); |
174 | 173 | $wgOut->disable(); |
175 | 174 | } |
| 175 | + |
| 176 | + return Status::newGood(); |
176 | 177 | } |
177 | 178 | |
178 | 179 | /** |
— | — | @@ -215,7 +216,7 @@ |
216 | 217 | |
217 | 218 | public function verifyUpload() { |
218 | 219 | if ( $this->chunkMode != self::DONE ) { |
219 | | - return Status::newGood(); |
| 220 | + return array('status' => UploadBase::OK); |
220 | 221 | } |
221 | 222 | return parent::verifyUpload(); |
222 | 223 | } |