r50227 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50226‎ | r50227 | r50228 >
Date:17:20, 5 May 2009
Author:dale
Status:deferred
Tags:
Comment:
improved http copy handling.
* progress updates and error handling
Modified paths:
  • /branches/new-upload/phase3/includes/HttpFunctions.php (modified) (history)
  • /branches/new-upload/phase3/includes/api/ApiUpload.php (modified) (history)

Diff [purge]

Index: branches/new-upload/phase3/includes/api/ApiUpload.php
@@ -164,28 +164,23 @@
165165 $this->dieUsageMsg( array( 'mustbeloggedin', 'upload' ) );
166166 else
167167 $this->dieUsageMsg( array( 'badaccess-groups' ) );
168 - }
169 - wfDebug("\n\n do perform UPLOAD\n");
 168+ }
170169 // Perform the upload
171170 $result = $this->performUpload();
172 - wfDebug("\n\ndid performUpload result: $result \n\n");
173171 // Cleanup any temporary mess
174172 $this->mUpload->cleanupTempFile();
175 - wfDebug("\n\n do output REsult:\n");
176173 $this->getResult()->addValue( null, $this->getModuleName(), $result );
177174 }
178175 private function performUpload() {
179176 global $wgUser;
180177 $result = array();
181 - $resultDetails = null;
182 - wfDebug("\n\n call verifyPermissions\n\n");
 178+ $resultDetails = null;
183179 $permErrors = $this->mUpload->verifyPermissions( $wgUser );
184180 if( $permErrors !== true ) {
185181 $result['result'] = 'Failure';
186182 $result['error'] = 'permission-denied';
187183 return $result;
188 - }
189 - wfDebug("\n\n call verifyUpload\n\n");
 184+ }
190185 $verification = $this->mUpload->verifyUpload( $resultDetails );
191186 if( $verification != UploadBase::OK ) {
192187 $result['result'] = 'Failure';
@@ -246,21 +241,19 @@
247242 $result['sessionkey'] = $sessionKey;
248243 return $result;
249244 }
250 - }
251 - wfDebug("\n\n call performUpload\n\n");
 245+ }
252246 //do the upload
253247 $status = $this->mUpload->performUpload( $this->mParams['comment'],
254248 $this->mParams['comment'], $this->mParams['watch'], $wgUser );
255 -
256 - wfDebug("\n\n check if status is good:".$status->isGood() . ' e: ' . print_r($status->getErrorsArray(), true). "\n\n");
 249+
257250 if( !$status->isGood() ) {
258251 $result['result'] = 'Failure';
259252 $result['error'] = 'internal-error';
260253 $result['details'] = $status->getErrorsArray();
261254 $this->getResult()->setIndexedTagName( $result['details'], 'error' );
262255 return $result;
263 - }
264 - wfDebug("\n\nstatus is good, get local file: \n");
 256+ }
 257+
265258 $file = $this->mUpload->getLocalFile();
266259 $result['result'] = 'Success';
267260 $result['filename'] = $file->getName();
Index: branches/new-upload/phase3/includes/HttpFunctions.php
@@ -125,9 +125,8 @@
126126 'upload_session_key' => $upload_session_key
127127 ) );
128128 //run the actual request .. (this can take some time)
129 - wfDebug("do Request: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
130 - $status = $req->doRequest();
131 - wfDebug("done with req status is: ". $status->isOK(). ' '.$status->value. "\n");
 129+ wfDebug("doRequest: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
 130+ $status = $req->doRequest();
132131
133132 if( $status->isOK() ){
134133
@@ -143,8 +142,7 @@
144143 $fauxReqData['action'] = 'upload';
145144 $fauxReqData['format'] = 'json';
146145 $fauxReqData['internalhttpsession'] = $upload_session_key;
147 - //evil but no other clean way about it:
148 -
 146+
149147 $faxReq = new FauxRequest($fauxReqData, true);
150148 $processor = new ApiMain($faxReq, $wgEnableWriteAPI);
151149
@@ -155,9 +153,7 @@
156154 $printer->initPrinter(false);
157155 ob_start();
158156 $printer->execute();
159 - $apiUploadResult = ob_get_clean();
160 -
161 - wfDebug("\n\n got:" . $apiUploadResult." \n");
 157+ $apiUploadResult = ob_get_clean();
162158
163159 wfDebug("\n\n got api result:: $apiUploadResult \n" );
164160 //the status updates runner will grab the result form the session:

Status & tagging log