Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -1019,4 +1019,10 @@ |
1020 | 1020 | return $blacklist; |
1021 | 1021 | } |
1022 | 1022 | |
| 1023 | + public function getImageInfo($result) { |
| 1024 | + $file = $this->getLocalFile(); |
| 1025 | + $imParam = ApiQueryImageInfo::getPropertyNames(); |
| 1026 | + return ApiQueryImageInfo::getInfo( $file, array_flip( $imParam ), $result ); |
| 1027 | + } |
| 1028 | + |
1023 | 1029 | } |
Index: trunk/phase3/includes/upload/UploadFromChunks.php |
— | — | @@ -88,8 +88,10 @@ |
89 | 89 | * @returns void |
90 | 90 | */ |
91 | 91 | protected function initFromSessionKey( $sessionKey, $sessionData ) { |
92 | | - if ( !$sessionKey || empty( $sessionKey ) ) { |
93 | | - $this->status = Status::newFromFatal( 'Missing session data.' ); |
| 92 | + // testing against null because we don't want to cause obscure |
| 93 | + // bugs when $sessionKey is full of "0" |
| 94 | + if ( !$sessionKey === null ) { |
| 95 | + $this->status = Status::newFromFatal( 'import-token-mismatch' ); |
94 | 96 | return; |
95 | 97 | } |
96 | 98 | $this->sessionKey = $sessionKey; |
— | — | @@ -115,7 +117,7 @@ |
116 | 118 | * @see UploadBase::performUpload |
117 | 119 | */ |
118 | 120 | public function performUpload( $comment, $pageText, $watch, $user ) { |
119 | | - wfDebug( "\n\n\performUpload(chunked): sum:" . $comment . ' c: ' . $pageText . ' w:' . $watch ); |
| 121 | + wfDebug( "\n\n\performUpload(chunked): comment:" . $comment . ' pageText: ' . $pageText . ' watch:' . $watch ); |
120 | 122 | global $wgUser, $wgOut; |
121 | 123 | |
122 | 124 | if ( $this->chunkMode == self::INIT ) { |
— | — | @@ -147,13 +149,13 @@ |
148 | 150 | ); |
149 | 151 | $wgOut->disable(); |
150 | 152 | } else if ( $this->chunkMode == self::DONE ) { |
151 | | - if ( $comment == '' ) |
| 153 | + if ( !$comment ) |
152 | 154 | $comment = $this->comment; |
153 | 155 | |
154 | | - if ( $pageText == '' ) |
| 156 | + if ( !$pageText ) |
155 | 157 | $pageText = $this->pageText; |
156 | 158 | |
157 | | - if ( $watch == '' ) |
| 159 | + if ( !$watch ) |
158 | 160 | $watch = $this->watch; |
159 | 161 | |
160 | 162 | $status = parent::performUpload( $comment, $pageText, $watch, $user ); |
— | — | @@ -203,15 +205,34 @@ |
204 | 206 | $_SESSION['wsUploadData'][$this->sessionKey]['repoPath'] = $this->repoPath; |
205 | 207 | } |
206 | 208 | return $status; |
| 209 | + } |
| 210 | + if ( $this->getRealPath( $this->repoPath ) ) { |
| 211 | + $this->status = $this->appendToUploadFile( $this->repoPath, $this->mTempPath ); |
207 | 212 | } else { |
208 | | - if ( $this->getRealPath( $this->repoPath ) ) { |
209 | | - $this->status = $this->appendToUploadFile( $this->repoPath, $this->mTempPath ); |
210 | | - } else { |
211 | | - $this->status = Status::newFatal( 'filenotfound', $this->repoPath ); |
212 | | - } |
| 213 | + $this->status = Status::newFatal( 'filenotfound', $this->repoPath ); |
| 214 | + } |
| 215 | + if ( $this->fileSize > $wgMaxUploadSize ) |
| 216 | + $this->status = Status::newFatal( 'largefileserver' ); |
| 217 | + } |
213 | 218 | |
214 | | - if ( $this->fileSize > $wgMaxUploadSize ) |
215 | | - $this->status = Status::newFatal( 'largefileserver' ); |
| 219 | + public function verifyUpload() { |
| 220 | + if ( $this->chunkMode != self::DONE ) { |
| 221 | + return Status::newGood(); |
216 | 222 | } |
| 223 | + return parent::verifyUpload(); |
217 | 224 | } |
| 225 | + |
| 226 | + public function checkWarnings() { |
| 227 | + if ( $this->chunkMode != self::DONE ) { |
| 228 | + return null; |
| 229 | + } |
| 230 | + return parent::checkWarnings(); |
| 231 | + } |
| 232 | + |
| 233 | + public function getImageInfo( $result ) { |
| 234 | + if ( $this->chunkMode != self::DONE ) { |
| 235 | + return null; |
| 236 | + } |
| 237 | + return parent::getImageInfo( $result ); |
| 238 | + } |
218 | 239 | } |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -84,9 +84,9 @@ |
85 | 85 | if ( $this->mParams['enablechunks'] ) { |
86 | 86 | $this->mUpload = new UploadFromChunks(); |
87 | 87 | $this->mUpload->initialize( |
88 | | - $request->getText( 'done' ), |
89 | | - $request->getText( 'filename' ), |
90 | | - $request->getText( 'chunksessionkey' ), |
| 88 | + $request->getVal( 'done', null ), |
| 89 | + $request->getVal( 'filename', null ), |
| 90 | + $request->getVal( 'chunksessionkey', null ), |
91 | 91 | $request->getFileTempName( 'chunk' ), |
92 | 92 | $request->getFileSize( 'chunk' ), |
93 | 93 | $request->getSessionData( 'wsUploadData' ) |
— | — | @@ -126,13 +126,6 @@ |
127 | 127 | if ( !isset( $this->mUpload ) ) |
128 | 128 | $this->dieUsage( 'No upload module set', 'nomodule' ); |
129 | 129 | |
130 | | - |
131 | | - // Finish up the exec command: |
132 | | - $this->doExecUpload(); |
133 | | - } |
134 | | - |
135 | | - protected function doExecUpload() { |
136 | | - global $wgUser; |
137 | 130 | // Check whether the user has the appropriate permissions to upload anyway |
138 | 131 | $permission = $this->mUpload->isAllowed( $wgUser ); |
139 | 132 | |
— | — | @@ -144,8 +137,8 @@ |
145 | 138 | } |
146 | 139 | // Perform the upload |
147 | 140 | $result = $this->performUpload(); |
| 141 | + |
148 | 142 | // Cleanup any temporary mess |
149 | | - // FIXME: This should be in a try .. finally block with performUpload |
150 | 143 | $this->mUpload->cleanupTempFile(); |
151 | 144 | $this->getResult()->addValue( null, $this->getModuleName(), $result ); |
152 | 145 | } |
— | — | @@ -255,12 +248,8 @@ |
256 | 249 | $file = $this->mUpload->getLocalFile(); |
257 | 250 | $result['result'] = 'Success'; |
258 | 251 | $result['filename'] = $file->getName(); |
| 252 | + $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() ); |
259 | 253 | |
260 | | - // Append imageinfo to the result |
261 | | - $imParam = ApiQueryImageInfo::getPropertyNames(); |
262 | | - $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file, |
263 | | - array_flip( $imParam ), $this->getResult() ); |
264 | | - |
265 | 254 | return $result; |
266 | 255 | } |
267 | 256 | |