Index: branches/new-upload/phase3/includes/api/ApiUpload.php |
— | — | @@ -41,8 +41,9 @@ |
42 | 42 | global $wgUser; |
43 | 43 | $this->getMain()->requestWriteMode(); |
44 | 44 | $this->mParams = $this->extractRequestParams(); |
| 45 | + $request = $this->getMain()->getRequest(); |
45 | 46 | // Add the uploaded file to the params array |
46 | | - $this->mParams['file'] = $this->getMain()->getRequest()->getFileName('file'); |
| 47 | + $this->mParams['file'] = $request->getFileName('file'); |
47 | 48 | |
48 | 49 | // Check whether upload is enabled |
49 | 50 | if( !UploadFromBase::isEnabled() ) |
— | — | @@ -63,13 +64,9 @@ |
64 | 65 | // Parameter filename is required |
65 | 66 | if( !isset( $this->mParams['filename'] ) ) |
66 | 67 | $this->dieUsageMsg( array( 'missingparam', 'filename' ) ); |
67 | | - // Parameter comment defaults to '' |
68 | | - if( !isset( $this->mParams['comment'] ) ) |
69 | | - $this->mParams['comment'] = ''; |
70 | 68 | |
71 | 69 | // Initialize $this->mUpload |
72 | 70 | if( isset( $this->mParams['file'] ) ) { |
73 | | - $request = $this->getMain()->getRequest(); |
74 | 71 | $this->mUpload = new UploadFromUpload(); |
75 | 72 | $this->mUpload->initialize( |
76 | 73 | $request->getFileTempName( 'file' ), |
— | — | @@ -92,7 +89,7 @@ |
93 | 90 | } |
94 | 91 | |
95 | 92 | // Perform the upload |
96 | | - $result = $this->performUpload(); |
| 93 | + $result = $this->performUpload(); |
97 | 94 | |
98 | 95 | // Cleanup any temporary mess |
99 | 96 | $this->mUpload->cleanupTempFile(); |
— | — | @@ -154,7 +151,7 @@ |
155 | 152 | $result['error'] = 'unknown-error'; |
156 | 153 | $result['code'] = $verification; |
157 | 154 | break; |
158 | | - } |
| 155 | + } |
159 | 156 | return $result; |
160 | 157 | } |
161 | 158 | |
— | — | @@ -167,7 +164,7 @@ |
168 | 165 | $result['warnings'] = $warnings; |
169 | 166 | if( isset( $result['filewasdeleted'] ) ) |
170 | 167 | $result['filewasdeleted'] = $result['filewasdeleted']->getDBkey(); |
171 | | - |
| 168 | + |
172 | 169 | $sessionKey = $this->mUpload->stashSession(); |
173 | 170 | if( $sessionKey ) |
174 | 171 | $result['sessionkey'] = $sessionKey; |
— | — | @@ -177,7 +174,7 @@ |
178 | 175 | |
179 | 176 | $status = $this->mUpload->performUpload( $this->mParams['comment'], |
180 | 177 | $this->mParams['comment'], $this->mParams['watch'], $wgUser); |
181 | | - |
| 178 | + |
182 | 179 | if( !$status->isGood() ) { |
183 | 180 | $result['result'] = 'Failure'; |
184 | 181 | $result['error'] = 'internal-error'; |
— | — | @@ -191,8 +188,8 @@ |
192 | 189 | $result['filename'] = $file->getName(); |
193 | 190 | |
194 | 191 | // Append imageinfo to the result |
195 | | - $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file, |
196 | | - array_flip( ApiQueryImageInfo::allProps() ), |
| 192 | + $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file, |
| 193 | + array_flip( ApiQueryImageInfo::allProps() ), |
197 | 194 | $this->getResult() ); |
198 | 195 | |
199 | 196 | return $result; |
— | — | @@ -205,7 +202,9 @@ |
206 | 203 | 'filename' => null, |
207 | 204 | 'file' => null, |
208 | 205 | 'url' => null, |
209 | | - 'comment' => null, |
| 206 | + 'comment' => array( |
| 207 | + ApiBase :: PARAM_DFLT => '' |
| 208 | + ), |
210 | 209 | 'watch' => false, |
211 | 210 | 'ignorewarnings' => false, |
212 | 211 | 'sessionkey' => null, |
— | — | @@ -237,7 +236,7 @@ |
238 | 237 | } |
239 | 238 | |
240 | 239 | public function getVersion() { |
241 | | - return __CLASS__ . ': $Id: APiUpload.php 35619 2008-05-30 19:59:47Z btongminh $'; |
| 240 | + return __CLASS__ . ': $Id: ApiUpload.php 35619 2008-05-30 19:59:47Z btongminh $'; |
242 | 241 | } |
243 | 242 | } |
244 | 243 | |