r50286 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50285‎ | r50286 | r50287 >
Date:21:26, 6 May 2009
Author:dale
Status:deferred
Tags:
Comment:
updated error handling
Modified paths:
  • /branches/new-upload/phase3/includes/HttpFunctions.php (modified) (history)
  • /branches/new-upload/phase3/includes/api/ApiBase.php (modified) (history)

Diff [purge]

Index: branches/new-upload/phase3/includes/HttpFunctions.php
@@ -100,7 +100,6 @@
101101 */
102102 public static function doSessionIdDownload( $session_id, $upload_session_key ){
103103 global $wgUser, $wgEnableWriteAPI;
104 - wfDebug("\n\ndoSessionIdDownload\n\n");
105104 //set session to the provided key:
106105 session_id($session_id);
107106 //start the session
@@ -128,15 +127,14 @@
129128 wfDebug("doRequest: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
130129 $status = $req->doRequest();
131130
132 - if( $status->isOK() ){
133 -
134 - //start up the session again:
135 - if( session_start() === false){
136 - wfDebug( __METHOD__ . ' ERROR:: Could not start session');
137 - }
138 - //re-grab the updated session data:
139 - $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key];
140 -
 131+
 132+ //start up the session again:
 133+ if( session_start() === false){
 134+ wfDebug( __METHOD__ . ' ERROR:: Could not start session');
 135+ }
 136+ //re-grab the updated session data:
 137+ $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key];
 138+ if( $status->isOK() ){
141139 //setup the faxRequest
142140 $fauxReqData = $sd['mParams'];
143141 $fauxReqData['action'] = 'upload';
@@ -154,12 +152,14 @@
155153 ob_start();
156154 $printer->execute();
157155 $apiUploadResult = ob_get_clean();
158 -
159 - wfDebug("\n\n got api result:: $apiUploadResult \n" );
 156+
160157 //the status updates runner will grab the result form the session:
161 - $sd['apiUploadResult'] = $apiUploadResult;
162 - session_write_close();
 158+ $sd['apiUploadResult'] = $apiUploadResult;
 159+ }else{
 160+ //status != OK
 161+ $sd['apiUploadResult'] = ApiFormatJson::getJsonEncode( array( 'error' => $status->getWikiText() ) );
163162 }
 163+ session_write_close();
164164 }
165165
166166 /**
@@ -305,6 +305,7 @@
306306 if ( $retcode != 200 ) {
307307 wfDebug( __METHOD__ . ": HTTP return code $retcode\n" );
308308 $status = Status::newFatal( "HTTP return code $retcode\n" );
 309+
309310 }
310311 # Don't return truncated output
311312 $errno = curl_errno( $c );
Index: branches/new-upload/phase3/includes/api/ApiBase.php
@@ -147,9 +147,8 @@
148148 * Get the result object
149149 * @return ApiResult
150150 */
151 - public function getResult() {
152 - wfDebug("\n\napiBase:getResult()\n\n");
153 - // Main module has getResult() method overriden
 151+ public function getResult() {
 152+ // Main module has getResult() method overridden
154153 // Safety - avoid infinite loop:
155154 if ($this->isMain())
156155 ApiBase :: dieDebug(__METHOD__, 'base method was called on main module. ');

Status & tagging log