From 996d17d401e2aa72b17996e4c1ef2505fda68d42 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Mon, 27 Jul 2009 21:32:25 +0000 Subject: [PATCH] * ignorewarnings fixes * removed extra debug statement * supports do_close_session_update for php based requests --- includes/HttpFunctions.php | 22 +++++++++---------- includes/api/ApiUpload.php | 5 ++--- .../libAddMedia/mvBaseUploadInterface.js | 15 +++++++++---- js2/mwEmbed/libAddMedia/remoteSearchDriver.js | 12 +++++----- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 849ff7c00c..6d7713635b 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -286,7 +286,7 @@ class HttpRequest { $this->target_file_path = ( isset( $opt['target_file_path'] ) ) ? $opt['target_file_path'] : false; $this->upload_session_key = ( isset( $opt['upload_session_key'] ) ) ? $opt['upload_session_key'] : false; $this->headers_only = ( isset( $opt['headers_only'] ) ) ? $opt['headers_only'] : false; - $this->do_close_session_update = ( isset( $opt['do_close_session_update'] ) ) ? $opt['do_close_session_update'] : false; + $this->do_close_session_update = ( isset( $opt['do_close_session_update'] ) ) ? true : false; } /** @@ -461,7 +461,7 @@ class HttpRequest { // set the write back function (if we are writing to a file) if( $this->target_file_path ){ - $cwrite = new simpleFileWriter( $this->target_file_path, $this->upload_session_key ); + $cwrite = new simpleFileWriter( $this->target_file_path, $this->upload_session_key, $this->do_close_session_update ); if( !$cwrite->status->isOK() ){ wfDebug( __METHOD__ . "ERROR in setting up simpleFileWriter\n" ); $status = $cwrite->status; @@ -540,15 +540,15 @@ class simpleFileWriter { } // if more than session_update_interval second have passed update_session_progress - if( $this->do_close_session_update && - $this->upload_session_key && ( ( time() - $this->prevTime ) > $this->session_update_interval ) ) { - $this->prevTime = time(); - $session_status = $this->update_session_progress(); - if( !$session_status->isOK() ){ - $this->status = $session_status; - wfDebug( __METHOD__ . ' update session failed or was canceled'); - return 0; - } + if( $this->do_close_session_update && $this->upload_session_key && + ( ( time() - $this->prevTime ) > $this->session_update_interval ) ) { + $this->prevTime = time(); + $session_status = $this->update_session_progress(); + if( !$session_status->isOK() ){ + $this->status = $session_status; + wfDebug( __METHOD__ . ' update session failed or was canceled'); + return 0; + } } return strlen( $data_packet ); } diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index b4e0ddaedd..89dd1bec5c 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -72,8 +72,9 @@ class ApiUpload extends ApiBase { $this->dieUsageMsg( $this->mUpload->status['error'] ); } else if( $this->mParams['internalhttpsession'] ){ - $sd = & $_SESSION['wsDownload'][$this->mParams['internalhttpsession']]; + $sd = & $_SESSION['wsDownload'][ $this->mParams['internalhttpsession'] ]; + wfDebug("InternalHTTP:: " . print_r($this->mParams, true)); // get the params from the init session: $this->mUpload = new UploadFromFile(); @@ -274,8 +275,6 @@ class ApiUpload extends ApiBase { array_flip( $imProp ), $this->getResult() ); - wfDebug( "\n\n return result: " . print_r( $result, true ) ); - return $result; } diff --git a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js index 9b0efc43db..64089c7ffd 100644 --- a/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js +++ b/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js @@ -194,10 +194,12 @@ mvBaseUploadInterface.prototype = { var httpUpConf ={ 'url' : $j('#wpUploadFileURL').val(), 'filename' : $j('#wpDestFile').val(), - 'comment' : $j('#wpUploadDescription').val(), - 'ignorewarnings' : ($j('#wpIgnoreWarning').is(':checked')) ?'true':'false' , + 'comment' : $j('#wpUploadDescription').val(), 'watch' : ($j('#wpWatchthis').is(':checked'))?'true':'false' } + if( $j('#wpIgnoreWarning').is(':checked') ){ + httpUpConf[ 'ignorewarnings'] = 'true'; + } //check for editToken _this.etoken = $j("input[name='wpEditToken']").val(); _this.doHttpUpload( httpUpConf ); @@ -459,8 +461,13 @@ mvBaseUploadInterface.prototype = { _this.warnings_sessionkey = apiRes.upload.warnings.sessionkey; var bObj = {}; bObj[ gM('ignorewarning') ] = function() { - js_error('todo: ignore warnings action '); - }; + //re-inciate the upload proccess + $j('#wpIgnoreWarning').attr('checked', true); + $j( '#mw-upload-form' ).submit(); + }; + bObj[ gM('return-to-form') ] = function(){ + $j(this).dialog('close'); + } _this.updateProgressWin( gM('uploadwarning'), '

' + gM('uploadwarning') + '

' +wmsg + '

',bObj); return false; } diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index 8a3eddc24b..45ef3daf5c 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -1380,12 +1380,12 @@ remoteSearchDriver.prototype = { //not sure if we can do remote url uploads (so just do a local post) js_log('got token for new page:' +editToken); var postVars = { - 'wpSourceType' :'web', - 'wpUploadFileURL' : rObj.src, - 'wpDestFile' : rObj.target_resource_title, - 'wpUploadDescription' : $j('#rsd_import_ta').val(), - 'wpWatchthis' : $j('#wpWatchthis').val(), - 'wpUpload' : 'Upload file' + 'wpSourceType' :'web', + 'wpUploadFileURL' : rObj.src, + 'wpDestFile' : rObj.target_resource_title, + 'wpUploadDescription' : $j('#rsd_import_ta').val(), + 'wpWatchthis' : $j('#wpWatchthis').val(), + 'wpUpload' : 'Upload file' } //set to uploading: $j('#rsd_resource_import').append('