r46100 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46099‎ | r46100 | r46101 >
Date:22:36, 23 January 2009
Author:catrope
Status:deferred
Tags:
Comment:
new-upload branch:
ApiUpload.php:
* Set default for 'comment' to ''
* Move up $request declaration
* Whitespace fixes
Modified paths:
  • /branches/new-upload/phase3/includes/api/ApiUpload.php (modified) (history)

Diff [purge]

Index: branches/new-upload/phase3/includes/api/ApiUpload.php
@@ -41,8 +41,9 @@
4242 global $wgUser;
4343 $this->getMain()->requestWriteMode();
4444 $this->mParams = $this->extractRequestParams();
 45+ $request = $this->getMain()->getRequest();
4546 // Add the uploaded file to the params array
46 - $this->mParams['file'] = $this->getMain()->getRequest()->getFileName('file');
 47+ $this->mParams['file'] = $request->getFileName('file');
4748
4849 // Check whether upload is enabled
4950 if( !UploadFromBase::isEnabled() )
@@ -63,13 +64,9 @@
6465 // Parameter filename is required
6566 if( !isset( $this->mParams['filename'] ) )
6667 $this->dieUsageMsg( array( 'missingparam', 'filename' ) );
67 - // Parameter comment defaults to ''
68 - if( !isset( $this->mParams['comment'] ) )
69 - $this->mParams['comment'] = '';
7068
7169 // Initialize $this->mUpload
7270 if( isset( $this->mParams['file'] ) ) {
73 - $request = $this->getMain()->getRequest();
7471 $this->mUpload = new UploadFromUpload();
7572 $this->mUpload->initialize(
7673 $request->getFileTempName( 'file' ),
@@ -92,7 +89,7 @@
9390 }
9491
9592 // Perform the upload
96 - $result = $this->performUpload();
 93+ $result = $this->performUpload();
9794
9895 // Cleanup any temporary mess
9996 $this->mUpload->cleanupTempFile();
@@ -154,7 +151,7 @@
155152 $result['error'] = 'unknown-error';
156153 $result['code'] = $verification;
157154 break;
158 - }
 155+ }
159156 return $result;
160157 }
161158
@@ -167,7 +164,7 @@
168165 $result['warnings'] = $warnings;
169166 if( isset( $result['filewasdeleted'] ) )
170167 $result['filewasdeleted'] = $result['filewasdeleted']->getDBkey();
171 -
 168+
172169 $sessionKey = $this->mUpload->stashSession();
173170 if( $sessionKey )
174171 $result['sessionkey'] = $sessionKey;
@@ -177,7 +174,7 @@
178175
179176 $status = $this->mUpload->performUpload( $this->mParams['comment'],
180177 $this->mParams['comment'], $this->mParams['watch'], $wgUser);
181 -
 178+
182179 if( !$status->isGood() ) {
183180 $result['result'] = 'Failure';
184181 $result['error'] = 'internal-error';
@@ -191,8 +188,8 @@
192189 $result['filename'] = $file->getName();
193190
194191 // 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() ),
197194 $this->getResult() );
198195
199196 return $result;
@@ -205,7 +202,9 @@
206203 'filename' => null,
207204 'file' => null,
208205 'url' => null,
209 - 'comment' => null,
 206+ 'comment' => array(
 207+ ApiBase :: PARAM_DFLT => ''
 208+ ),
210209 'watch' => false,
211210 'ignorewarnings' => false,
212211 'sessionkey' => null,
@@ -237,7 +236,7 @@
238237 }
239238
240239 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 $';
242241 }
243242 }
244243

Status & tagging log