Revision: 46100
Author:   catrope
Date:     2009-01-23 22:36:09 +0000 (Fri, 23 Jan 2009)

Log Message:
-----------
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: branches/new-upload/phase3/includes/api/ApiUpload.php
===================================================================
--- branches/new-upload/phase3/includes/api/ApiUpload.php       2009-01-23 
20:39:54 UTC (rev 46099)
+++ branches/new-upload/phase3/includes/api/ApiUpload.php       2009-01-23 
22:36:09 UTC (rev 46100)
@@ -41,8 +41,9 @@
                global $wgUser;
                $this->getMain()->requestWriteMode();
                $this->mParams = $this->extractRequestParams();
+               $request = $this->getMain()->getRequest();
                // Add the uploaded file to the params array
-               $this->mParams['file'] = 
$this->getMain()->getRequest()->getFileName('file');
+               $this->mParams['file'] = $request->getFileName('file');
                
                // Check whether upload is enabled
                if( !UploadFromBase::isEnabled() )
@@ -63,13 +64,9 @@
                        // Parameter filename is required
                        if( !isset( $this->mParams['filename'] ) )
                                $this->dieUsageMsg( array( 'missingparam', 
'filename' ) );
-                       // Parameter comment defaults to ''
-                       if( !isset( $this->mParams['comment'] ) )
-                               $this->mParams['comment'] = '';
                        
                        // Initialize $this->mUpload
                        if( isset( $this->mParams['file'] ) ) {
-                               $request = $this->getMain()->getRequest();
                                $this->mUpload = new UploadFromUpload();
                                $this->mUpload->initialize(
                                        $request->getFileTempName( 'file' ),
@@ -92,7 +89,7 @@
                }
                
                // Perform the upload
-               $result = $this->performUpload();               
+               $result = $this->performUpload();
                
                // Cleanup any temporary mess
                $this->mUpload->cleanupTempFile();
@@ -154,7 +151,7 @@
                                        $result['error'] = 'unknown-error';
                                        $result['code'] = $verification;
                                        break;
-                       }                               
+                       }
                        return $result;
                }
                
@@ -167,7 +164,7 @@
                                $result['warnings'] = $warnings;
                                if( isset( $result['filewasdeleted'] ) )
                                        $result['filewasdeleted'] = 
$result['filewasdeleted']->getDBkey();
-                                       
+                               
                                $sessionKey = $this->mUpload->stashSession();
                                if( $sessionKey )
                                        $result['sessionkey'] = $sessionKey;
@@ -177,7 +174,7 @@
                
                $status = $this->mUpload->performUpload( 
$this->mParams['comment'],
                        $this->mParams['comment'], $this->mParams['watch'], 
$wgUser);
-                       
+               
                if( !$status->isGood() ) {
                        $result['result'] = 'Failure';
                        $result['error'] = 'internal-error';
@@ -191,8 +188,8 @@
                $result['filename'] = $file->getName();
                
                // Append imageinfo to the result
-               $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file, 
-                       array_flip( ApiQueryImageInfo::allProps() ), 
+               $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file,
+                       array_flip( ApiQueryImageInfo::allProps() ),
                        $this->getResult() );
                
                return $result; 
@@ -205,7 +202,9 @@
                        'filename' => null,
                        'file' => null,
                        'url' => null,
-                       'comment' => null,
+                       'comment' => array(
+                               ApiBase :: PARAM_DFLT => ''
+                       ),
                        'watch' => false,
                        'ignorewarnings' => false,
                        'sessionkey' => null,
@@ -237,7 +236,7 @@
        }
 
        public function getVersion() {
-               return __CLASS__ . ': $Id: APiUpload.php 35619 2008-05-30 
19:59:47Z btongminh $';
+               return __CLASS__ . ': $Id: ApiUpload.php 35619 2008-05-30 
19:59:47Z btongminh $';
        }
 }
 



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to