r53700 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53699‎ | r53700 | r53701 >
Date:21:28, 23 July 2009
Author:dale
Status:ok
Tags:
Comment:
fixes bug 19736
If you did not have the wgServer var set manually the internal shell request for the download would result in localhost being used for the API result url.
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HttpFunctions.php
@@ -94,7 +94,7 @@
9595 *
9696 */
9797 private function initBackgroundDownload( $url, $target_file_path, $content_length = null ){
98 - global $wgMaxUploadSize, $IP, $wgPhpCli;
 98+ global $wgMaxUploadSize, $IP, $wgPhpCli, $wgServer;
9999 $status = Status::newGood();
100100
101101 // generate a session id with all the details for the download (pid, target_file_path )
@@ -104,6 +104,8 @@
105105 // store the url and target path:
106106 $_SESSION['wsDownload'][$upload_session_key]['url'] = $url;
107107 $_SESSION['wsDownload'][$upload_session_key]['target_file_path'] = $target_file_path;
 108+ //since we request from the cmd line we lose the original host name pass in the session:
 109+ $_SESSION['wsDownload'][$upload_session_key]['orgServer'] = $wgServer;
108110
109111 if( $content_length )
110112 $_SESSION['wsDownload'][$upload_session_key]['content_length'] = $content_length;
@@ -139,8 +141,8 @@
140142 * (a given client could have started a few http uploads at once)
141143 */
142144 public static function doSessionIdDownload( $session_id, $upload_session_key ){
143 - global $wgUser, $wgEnableWriteAPI, $wgAsyncHTTPTimeout;
144 - wfDebug( __METHOD__ . "\n\ndoSessionIdDownload\n\n" );
 145+ global $wgUser, $wgEnableWriteAPI, $wgAsyncHTTPTimeout, $wgServer;
 146+ wfDebug( __METHOD__ . "\n\ndoSessionIdDownload:\n\n" );
145147 // set session to the provided key:
146148 session_id( $session_id );
147149 // start the session
@@ -156,7 +158,12 @@
157159 $wgUser = User::newFromSession();
158160
159161 // grab the session data to setup the request:
160 - $sd =& $_SESSION['wsDownload'][$upload_session_key];
 162+ $sd =& $_SESSION['wsDownload'][$upload_session_key];
 163+
 164+ //update the wgServer var ( since cmd line thinks we are localhost when we are really orgServer)
 165+ if(isset($sd['orgServer']) && $sd['orgServer']){
 166+ $wgServer = $sd['orgServer'];
 167+ }
161168 // close down the session so we can other http queries can get session updates:
162169 session_write_close();
163170

Status & tagging log