r51755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51754‎ | r51755 | r51756 >
Date:19:43, 11 June 2009
Author:dale
Status:deferred
Tags:
Comment:
restored static Http::request support
Modified paths:
  • /branches/new-upload/phase3/includes/HttpFunctions.php (modified) (history)
  • /branches/new-upload/phase3/includes/Import.php (modified) (history)

Diff [purge]

Index: branches/new-upload/phase3/includes/HttpFunctions.php
@@ -6,192 +6,200 @@
77
88
99 class Http {
10 - const SYNC_DOWNLOAD = 1; //syncronys upload (in a single request)
 10+ const SYNC_DOWNLOAD = 1; //syncronys upload (in a single request)
1111 const ASYNC_DOWNLOAD = 2; //asynchronous upload we should spawn out another process and monitor progress if possible)
1212
13 - var $body = '';
 13+ var $body = '';
 14+ public static function request( $url, $opts = array() ) {
 15+ $req = new HttpRequest( $url, $opts );
 16+ $status = $req->doRequest();
 17+ if( $status->isOK() ){
 18+ return $status->value;
 19+ }else{
 20+ return false;
 21+ }
 22+ }
1423 /**
1524 * Simple wrapper for Http::request( 'GET' )
1625 */
17 - public static function get( $url, $opts = array() ) {
18 - $opt['method'] = 'GET';
19 - $req = new HttpRequest($url, $opts );
20 - return $req->doRequest();
21 - }
 26+ public static function get( $url, $opts = array() ) {
 27+ $opt['method'] = 'GET';
 28+ return Http::request($url, $opts);
 29+ }
2230 /**
2331 * Simple wrapper for Http::request( 'POST' )
2432 */
2533 public static function post( $url, $opts = array() ) {
2634 $opts['method']='POST';
27 - $req = new HttpRequest( $url, $opts );
28 - return $req->doRequest();
 35+ return Http::request($url, $opts);
2936 }
 37+
3038 public static function doDownload( $url, $target_file_path , $dl_mode = self::SYNC_DOWNLOAD , $redirectCount=0){
31 - global $wgPhpCliPath, $wgMaxUploadSize, $wgMaxRedirects;
32 - //do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize
33 - $head = get_headers($url, 1);
34 -
 39+ global $wgPhpCliPath, $wgMaxUploadSize, $wgMaxRedirects;
 40+ //do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize
 41+ $head = get_headers($url, 1);
 42+
3543 //check for redirects:
3644 if( isset( $head['Location'] ) && strrpos($head[0], '302')!==false ){
3745 if($redirectCount < $wgMaxRedirects){
38 - if( UploadFromUrl::isValidURI( $head['Location'] )){
 46+ if( UploadFromUrl::isValidURI( $head['Location'] )){
3947 return self::doDownload ( $head['Location'], $target_file_path , $dl_mode, $redirectCount++);
4048 }else{
41 - return Status::newFatal('upload-proto-error');
42 - }
 49+ return Status::newFatal('upload-proto-error');
 50+ }
4351 }else{
44 - return Status::newFatal('upload-too-many-redirects');
 52+ return Status::newFatal('upload-too-many-redirects');
4553 }
46 - }
47 - //we did not get a 200 ok response:
 54+ }
 55+ //we did not get a 200 ok response:
4856 if( strrpos($head[0], '200 OK') === false){
49 - return Status::newFatal( 'upload-http-error', htmlspecialchars($head[0]) );
 57+ return Status::newFatal( 'upload-http-error', htmlspecialchars($head[0]) );
5058 }
51 -
52 -
53 - $content_length = (isset($head['Content-Length']))?$head['Content-Length']:null;
 59+
 60+
 61+ $content_length = (isset($head['Content-Length']))?$head['Content-Length']:null;
5462 if($content_length){
55 - if($content_length > $wgMaxUploadSize){
56 - return Status::newFatal('requested file length ' . $content_length . ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize);
57 - }
58 - }
59 -
60 - //check if we can find phpCliPath (for doing a background shell request to php to do the download:
61 - if( $wgPhpCliPath && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD){
 63+ if($content_length > $wgMaxUploadSize){
 64+ return Status::newFatal('requested file length ' . $content_length . ' is greater than $wgMaxUploadSize: ' . $wgMaxUploadSize);
 65+ }
 66+ }
 67+
 68+ //check if we can find phpCliPath (for doing a background shell request to php to do the download:
 69+ if( $wgPhpCliPath && wfShellExecEnabled() && $dl_mode == self::ASYNC_DOWNLOAD){
6270 wfDebug("\ASYNC_DOWNLOAD\n");
63 - //setup session and shell call:
64 - return self::initBackgroundDownload( $url, $target_file_path, $content_length );
 71+ //setup session and shell call:
 72+ return self::initBackgroundDownload( $url, $target_file_path, $content_length );
6573 }else if( $dl_mode== self::SYNC_DOWNLOAD ){
6674 wfDebug("\nSYNC_DOWNLOAD\n");
6775 //SYNC_DOWNLOAD download as much as we can in the time we have to execute
6876 $opts['method']='GET';
6977 $opts['target_file_path'] = $target_file_path;
70 - $req = new HttpRequest($url, $opts );
71 - return $req->doRequest();
72 - }
 78+ $req = new HttpRequest($url, $opts );
 79+ return $req->doRequest();
 80+ }
7381 }
7482 /**
7583 * a non blocking request (generally an exit point in the application)
76 - * should write to a file location and give updates
77 - *
 84+ * should write to a file location and give updates
 85+ *
7886 */
7987 private function initBackgroundDownload( $url, $target_file_path, $content_length = null ){
8088 global $wgMaxUploadSize, $IP, $wgPhpCliPath;
81 - $status = Status::newGood();
82 -
83 - //generate a session id with all the details for the download (pid, target_file_path )
84 - $upload_session_key = self::getUploadSessionKey();
 89+ $status = Status::newGood();
 90+
 91+ //generate a session id with all the details for the download (pid, target_file_path )
 92+ $upload_session_key = self::getUploadSessionKey();
8593 $session_id = session_id();
86 -
87 - //store the url and target path:
 94+
 95+ //store the url and target path:
8896 $_SESSION[ 'wsDownload' ][$upload_session_key]['url'] = $url;
89 - $_SESSION[ 'wsDownload' ][$upload_session_key]['target_file_path'] = $target_file_path;
90 -
 97+ $_SESSION[ 'wsDownload' ][$upload_session_key]['target_file_path'] = $target_file_path;
 98+
9199 if($content_length)
92100 $_SESSION[ 'wsDownload' ][$upload_session_key]['content_length'] = $content_length;
93101
94102 //set initial loaded bytes:
95103 $_SESSION[ 'wsDownload' ][$upload_session_key]['loaded'] = 0;
96 -
97 -
98 - //run the background download request:
99 - $cmd = $wgPhpCliPath . ' ' . $IP . "/maintenance/http_session_download.php --sid {$session_id} --usk {$upload_session_key}";
100 - $pid = wfShellBackgroundExec($cmd , $retval);
101 - //the pid is not of much use since we won't be visiting this same apache any-time soon.
 104+
 105+
 106+ //run the background download request:
 107+ $cmd = $wgPhpCliPath . ' ' . $IP . "/maintenance/http_session_download.php --sid {$session_id} --usk {$upload_session_key}";
 108+ $pid = wfShellBackgroundExec($cmd , $retval);
 109+ //the pid is not of much use since we won't be visiting this same apache any-time soon.
102110 if(!$pid)
103111 return Status::newFatal('could not run background shell exec');
104 -
105 - //update the status value with the $upload_session_key (for the user to check on the status of the upload)
 112+
 113+ //update the status value with the $upload_session_key (for the user to check on the status of the upload)
106114 $status->value = $upload_session_key;
107 -
 115+
108116 //return good status
109 - return $status;
110 - }
 117+ return $status;
 118+ }
111119 function getUploadSessionKey(){
112120 $key = mt_rand( 0, 0x7fffffff );
113121 $_SESSION['wsUploadData'][$key] = array();
114122 return $key;
115 - }
 123+ }
116124 /**
117 - * used to run a session based download. Is initiated via the shell.
 125+ * used to run a session based download. Is initiated via the shell.
118126 *
119127 * @param string $session_id // the session id to grab download details from
120 - * @param string $upload_session_key //the key of the given upload session
 128+ * @param string $upload_session_key //the key of the given upload session
121129 * (a given client could have started a few http uploads at once)
122130 */
123131 public static function doSessionIdDownload( $session_id, $upload_session_key ){
124 - global $wgUser, $wgEnableWriteAPI, $wgAsyncHTTPTimeout;
 132+ global $wgUser, $wgEnableWriteAPI, $wgAsyncHTTPTimeout;
125133 wfDebug("\n\ndoSessionIdDownload\n\n");
126134 //set session to the provided key:
127135 session_id($session_id);
128 - //start the session
 136+ //start the session
129137 if( session_start() === false){
130 - wfDebug( __METHOD__ . ' could not start session');
 138+ wfDebug( __METHOD__ . ' could not start session');
131139 }
132 - //get all the vars we need from session_id
 140+ //get all the vars we need from session_id
133141 if(!isset($_SESSION[ 'wsDownload' ][$upload_session_key])){
134142 wfDebug( __METHOD__ .' Error:could not find upload session');
135143 exit();
136144 }
137145 //setup the global user from the session key we just inherited
138146 $wgUser = User::newFromSession();
139 -
140 - //grab the session data to setup the request:
 147+
 148+ //grab the session data to setup the request:
141149 $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key];
142150 //close down the session so we can other http queries can get session updates:
143 - session_write_close();
144 -
 151+ session_write_close();
 152+
145153 $req = new HttpRequest( $sd['url'], array(
146 - 'target_file_path' => $sd['target_file_path'],
147 - 'upload_session_key'=> $upload_session_key,
 154+ 'target_file_path' => $sd['target_file_path'],
 155+ 'upload_session_key'=> $upload_session_key,
148156 'timeout' => $wgAsyncHTTPTimeout
149 - ) );
150 - //run the actual request .. (this can take some time)
 157+ ) );
 158+ //run the actual request .. (this can take some time)
151159 wfDebug("do Request: " . $sd['url'] . ' tf: ' . $sd['target_file_path'] );
152 - $status = $req->doRequest();
 160+ $status = $req->doRequest();
153161 //wfDebug("done with req status is: ". $status->isOK(). ' '.$status->getWikiText(). "\n");
154162
155 - //start up the session again:
 163+ //start up the session again:
156164 if( session_start() === false){
157 - wfDebug( __METHOD__ . ' ERROR:: Could not start session');
158 - }
159 - //grab the updated session data pointer
160 - $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key];
161 - //if error update status:
 165+ wfDebug( __METHOD__ . ' ERROR:: Could not start session');
 166+ }
 167+ //grab the updated session data pointer
 168+ $sd =& $_SESSION[ 'wsDownload' ][$upload_session_key];
 169+ //if error update status:
162170 if( !$status->isOK() ){
163 - $sd['apiUploadResult']= ApiFormatJson::getJsonEncode(
 171+ $sd['apiUploadResult']= ApiFormatJson::getJsonEncode(
164172 array( 'error' => $status->getWikiText() )
165173 );
166 - }
167 - //if status oky process upload using fauxReq to api:
168 - if( $status->isOK() ){
 174+ }
 175+ //if status oky process upload using fauxReq to api:
 176+ if( $status->isOK() ){
169177 //setup the faxRequest
170 - $fauxReqData = $sd['mParams'];
171 - $fauxReqData['action'] = 'upload';
 178+ $fauxReqData = $sd['mParams'];
 179+ $fauxReqData['action'] = 'upload';
172180 $fauxReqData['format'] = 'json';
173 - $fauxReqData['internalhttpsession'] = $upload_session_key;
174 - //evil but no other clean way about it:
175 -
176 - $faxReq = new FauxRequest($fauxReqData, true);
 181+ $fauxReqData['internalhttpsession'] = $upload_session_key;
 182+ //evil but no other clean way about it:
 183+
 184+ $faxReq = new FauxRequest($fauxReqData, true);
177185 $processor = new ApiMain($faxReq, $wgEnableWriteAPI);
178 -
179 - //init the mUpload var for the $processor
180 - $processor->execute();
181 - $processor->getResult()->cleanUpUTF8();
 186+
 187+ //init the mUpload var for the $processor
 188+ $processor->execute();
 189+ $processor->getResult()->cleanUpUTF8();
182190 $printer = $processor->createPrinterByName('json');
183 - $printer->initPrinter(false);
 191+ $printer->initPrinter(false);
184192 ob_start();
185193 $printer->execute();
186 - $apiUploadResult = ob_get_clean();
187 -
 194+ $apiUploadResult = ob_get_clean();
 195+
188196 wfDebug("\n\n got api result:: $apiUploadResult \n" );
189 - //the status updates runner will grab the result form the session:
190 - $sd['apiUploadResult'] = $apiUploadResult;
 197+ //the status updates runner will grab the result form the session:
 198+ $sd['apiUploadResult'] = $apiUploadResult;
191199 }
192 - //close the session:
193 - session_write_close();
 200+ //close the session:
 201+ session_write_close();
194202 }
195 -
 203+
196204 /**
197205 * Check if the URL can be served by localhost
198206 * @param $url string Full url to check
@@ -225,7 +233,7 @@
226234 }
227235 return false;
228236 }
229 -
 237+
230238 /**
231239 * Return a standard user-agent we can use for external requests.
232240 */
@@ -241,45 +249,45 @@
242250 global $wgSyncHTTPTimeout;
243251 $this->url = $url;
244252 //set the timeout to default sync timeout (unless the timeout option is provided)
245 - $this->timeout = (isset($opt['timeout']))?$opt['timeout']:$wgSyncHTTPTimeout;
246 - $this->method = (isset($opt['method']))?$opt['method']:'GET';
 253+ $this->timeout = (isset($opt['timeout']))?$opt['timeout']:$wgSyncHTTPTimeout;
 254+ $this->method = (isset($opt['method']))?$opt['method']:'GET';
247255 $this->target_file_path = (isset($opt['target_file_path']))?$opt['target_file_path']:false;
248 - $this->upload_session_key = (isset($opt['upload_session_key']))?$opt['upload_session_key']:false;
 256+ $this->upload_session_key = (isset($opt['upload_session_key']))?$opt['upload_session_key']:false;
249257 }
250258 /**
251259 * Get the contents of a file by HTTP
252 - * @param $url string Full URL to act on
 260+ * @param $url string Full URL to act on
253261 * @param $Opt associative array Optional array of options:
254 - * 'method' => 'GET', 'POST' etc.
 262+ * 'method' => 'GET', 'POST' etc.
255263 * 'target_file_path' => if curl should output to a target file
256264 * 'adapter' => 'curl', 'soket'
257265 */
258 - public function doRequest() {
 266+ public function doRequest() {
259267 # Use curl if available
260 - if ( function_exists( 'curl_init' ) ) {
 268+ if ( function_exists( 'curl_init' ) ) {
261269 return $this->doCurlReq();
262 - }else{
 270+ }else{
263271 return $this->doPhpReq();
264272 }
265273 }
266274 private function doCurlReq(){
267275 global $wgHTTPProxy, $wgTitle;
268 -
269 - $status = Status::newGood();
270 - $c = curl_init( $this->url );
271 -
272 - //proxy setup:
 276+
 277+ $status = Status::newGood();
 278+ $c = curl_init( $this->url );
 279+
 280+ //proxy setup:
273281 if ( Http::isLocalURL( $this->url ) ) {
274282 curl_setopt( $c, CURLOPT_PROXY, 'localhost:80' );
275283 } else if ($wgHTTPProxy) {
276284 curl_setopt($c, CURLOPT_PROXY, $wgHTTPProxy);
277285 }
278 -
279 - curl_setopt( $c, CURLOPT_TIMEOUT, $this->timeout );
280 -
281 -
 286+
 287+ curl_setopt( $c, CURLOPT_TIMEOUT, $this->timeout );
 288+
 289+
282290 curl_setopt( $c, CURLOPT_USERAGENT, Http::userAgent() );
283 -
 291+
284292 if ( $this->method == 'POST' ) {
285293 curl_setopt( $c, CURLOPT_POST, true );
286294 curl_setopt( $c, CURLOPT_POSTFIELDS, '' );
@@ -295,21 +303,21 @@
296304 if ( is_object( $wgTitle ) ) {
297305 curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() );
298306 }
299 -
300 - //set the write back function (if we are writing to a file)
301 - if( $this->target_file_path ){
302 - $cwrite = new simpleFileWriter( $this->target_file_path, $this->upload_session_key );
 307+
 308+ //set the write back function (if we are writing to a file)
 309+ if( $this->target_file_path ){
 310+ $cwrite = new simpleFileWriter( $this->target_file_path, $this->upload_session_key );
303311 if(!$cwrite->status->isOK()){
304 - wfDebug("ERROR in setting up simpleFileWriter\n");
305 - $status = $cwrite->status;
 312+ wfDebug("ERROR in setting up simpleFileWriter\n");
 313+ $status = $cwrite->status;
306314 }
307315 curl_setopt( $c, CURLOPT_WRITEFUNCTION, array($cwrite, 'callbackWriteBody') );
308316 }
309317
310 - //start output grabber:
 318+ //start output grabber:
311319 if(!$this->target_file_path)
312 - ob_start();
313 -
 320+ ob_start();
 321+
314322 //run the actual curl_exec:
315323 try {
316324 if (false === curl_exec($c)) {
@@ -319,20 +327,20 @@
320328 }
321329 } catch (Exception $e) {
322330 //do something with curl exec error?
323 - }
324 - //if direct request output the results to the stats value:
325 - if( !$this->target_file_path && $status->isOK() ){
 331+ }
 332+ //if direct request output the results to the stats value:
 333+ if( !$this->target_file_path && $status->isOK() ){
326334 $status->value = ob_get_contents();
327335 ob_end_clean();
328 - }
 336+ }
329337 //if we wrote to a target file close up or return error
330338 if( $this->target_file_path ){
331 - $cwrite->close();
 339+ $cwrite->close();
332340 if( ! $cwrite->status->isOK() ){
333 - return $cwrite->status;
 341+ return $cwrite->status;
334342 }
335343 }
336 -
 344+
337345 # Don't return the text of error messages, return false on error
338346 $retcode = curl_getinfo( $c, CURLINFO_HTTP_CODE );
339347 if ( $retcode != 200 ) {
@@ -346,13 +354,13 @@
347355 wfDebug( __METHOD__ . ": CURL error code $errno: $errstr\n" );
348356 $status = Status::newFatal( " CURL error code $errno: $errstr\n" );
349357 }
350 - curl_close( $c );
351 -
352 - //return the result obj
353 - return $status;
 358+ curl_close( $c );
 359+
 360+ //return the result obj
 361+ return $status;
354362 }
355363 public function doPhpReq(){
356 - #$use file_get_contents...
 364+ #$use file_get_contents...
357365 # This doesn't have local fetch capabilities...
358366
359367 $headers = array( "User-Agent: " . self :: userAgent() );
@@ -375,15 +383,15 @@
376384 }
377385 }
378386 /**
379 - * a simpleFileWriter with session id updates
380 - *
 387+ * a simpleFileWriter with session id updates
 388+ *
381389 */
382390 class simpleFileWriter{
383391 var $target_file_path;
384 - var $status = null;
385 - var $session_id = null;
386 - var $session_update_interval = 0; //how offten to update the session while downloading
387 -
 392+ var $status = null;
 393+ var $session_id = null;
 394+ var $session_update_interval = 0; //how offten to update the session while downloading
 395+
388396 function simpleFileWriter($target_file_path, $upload_session_key){
389397 $this->target_file_path = $target_file_path;
390398 $this->upload_session_key = $upload_session_key;
@@ -391,32 +399,32 @@
392400 //open the file:
393401 $this->fp = fopen( $this->target_file_path, 'w');
394402 if( $this->fp === false ){
395 - $this->status = Status::newFatal('HTTP::could-not-open-file-for-writing');
 403+ $this->status = Status::newFatal('HTTP::could-not-open-file-for-writing');
396404 }
397405 //true start time
398406 $this->prevTime = time();
399407 }
400408 public function callbackWriteBody($ch, $data_packet){
401 - global $wgMaxUploadSize;
402 -
 409+ global $wgMaxUploadSize;
 410+
403411 //write out the content
404412 if( fwrite($this->fp, $data_packet) === false){
405413 wfDebug(__METHOD__ ." ::could-not-write-to-file\n");
406414 $this->status = Status::newFatal('HTTP::could-not-write-to-file');
407415 return 0;
408 - }
409 -
410 - //check file size:
 416+ }
 417+
 418+ //check file size:
411419 clearstatcache();
412420 $this->current_fsize = filesize( $this->target_file_path);
413 -
 421+
414422 if( $this->current_fsize > $wgMaxUploadSize){
415423 wfDebug( __METHOD__ . " ::http download too large\n");
416 - $this->status = Status::newFatal('HTTP::file-has-grown-beyond-upload-limit-killing: downloaded more than ' .
417 - Language::formatSize($wgMaxUploadSize) . ' ');
 424+ $this->status = Status::newFatal('HTTP::file-has-grown-beyond-upload-limit-killing: downloaded more than ' .
 425+ Language::formatSize($wgMaxUploadSize) . ' ');
418426 return 0;
419 - }
420 -
 427+ }
 428+
421429 //if more than session_update_interval second have passed update_session_progress
422430 if($this->upload_session_key && ( (time() - $this->prevTime) > $this->session_update_interval )) {
423431 $this->prevTime = time();
@@ -426,35 +434,35 @@
427435 wfDebug( __METHOD__ . ' update session failed or was canceled');
428436 return 0;
429437 }
430 - }
431 - return strlen( $data_packet );
 438+ }
 439+ return strlen( $data_packet );
432440 }
433441 public function update_session_progress(){
434442 $status = Status::newGood();
435 - //start the session
 443+ //start the session
436444 if( session_start() === false){
437445 wfDebug( __METHOD__ . ' could not start session');
438 - exit(0);
439 - }
 446+ exit(0);
 447+ }
440448 $sd =& $_SESSION[ 'wsDownload' ][ $this->upload_session_key ];
441 - //check if the user canceled the request:
 449+ //check if the user canceled the request:
442450 if( $sd['user_cancel'] == true ){
443451 //kill the download
444 - return Status::newFatal('user-canceled-request');
445 - }
446 - //update the progress bytes download so far:
 452+ return Status::newFatal('user-canceled-request');
 453+ }
 454+ //update the progress bytes download so far:
447455 $sd['loaded'] = $this->current_fsize;
448456 wfDebug('set session loaded amount to: ' . $sd['loaded'] . "\n");
449457 //close down the session so we can other http queries can get session updates:
450 - session_write_close();
451 - return $status;
 458+ session_write_close();
 459+ return $status;
452460 }
453 - public function close(){
454 - //do a final session update:
 461+ public function close(){
 462+ //do a final session update:
455463 $this->update_session_progress();
456 - //close up the file handle:
 464+ //close up the file handle:
457465 if(false === fclose( $this->fp )){
458466 $this->status = Status::newFatal('HTTP::could-not-close-file');
459 - }
 467+ }
460468 }
461469 }
\ No newline at end of file
Index: branches/new-upload/phase3/includes/Import.php
@@ -90,15 +90,15 @@
9191 function setSize( $size ) {
9292 $this->size = intval( $size );
9393 }
94 -
 94+
9595 function setType( $type ) {
9696 $this->type = $type;
9797 }
98 -
 98+
9999 function setAction( $action ) {
100100 $this->action = $action;
101101 }
102 -
 102+
103103 function setParams( $params ) {
104104 $this->params = $params;
105105 }
@@ -142,15 +142,15 @@
143143 function getSize() {
144144 return $this->size;
145145 }
146 -
 146+
147147 function getType() {
148148 return $this->type;
149149 }
150 -
 150+
151151 function getAction() {
152152 return $this->action;
153153 }
154 -
 154+
155155 function getParams() {
156156 return $this->params;
157157 }
@@ -209,7 +209,7 @@
210210 ) );
211211 $revId = $revision->insertOn( $dbw );
212212 $changed = $article->updateIfNewerOn( $dbw, $revision );
213 -
 213+
214214 # To be on the safe side...
215215 $tempTitle = $GLOBALS['wgTitle'];
216216 $GLOBALS['wgTitle'] = $this->title;
@@ -237,12 +237,12 @@
238238
239239 return true;
240240 }
241 -
 241+
242242 function importLogItem() {
243243 $dbw = wfGetDB( DB_MASTER );
244244 # FIXME: this will not record autoblocks
245245 if( !$this->getTitle() ) {
246 - wfDebug( __METHOD__ . ": skipping invalid {$this->type}/{$this->action} log time, timestamp " .
 246+ wfDebug( __METHOD__ . ": skipping invalid {$this->type}/{$this->action} log time, timestamp " .
247247 $this->timestamp . "\n" );
248248 return;
249249 }
@@ -261,7 +261,7 @@
262262 );
263263 // FIXME: this could fail slightly for multiple matches :P
264264 if( $prior ) {
265 - wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
 265+ wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
266266 $this->timestamp . "\n" );
267267 return false;
268268 }
@@ -355,7 +355,7 @@
356356 // @fixme!
357357 $src = $this->getSrc();
358358 $status = Http::get( $src );
359 - if( !$status->isOK() ){
 359+ if( !$status->isOK() ){
360360 if( !$data ) {
361361 wfDebug( "IMPORT: couldn't fetch source $src\n" );
362362 fclose( $f );
@@ -415,7 +415,7 @@
416416 return($name);
417417 }
418418 }
419 -
 419+
420420 # --------------
421421
422422 function doImport() {
@@ -516,7 +516,7 @@
517517 $this->mUploadCallback = $callback;
518518 return $previous;
519519 }
520 -
 520+
521521 /**
522522 * Sets the action to perform as each log item reached.
523523 * @param $callback callback
@@ -552,7 +552,7 @@
553553 $dbw = wfGetDB( DB_MASTER );
554554 return $dbw->deadlockLoop( array( $revision, 'importOldRevision' ) );
555555 }
556 -
 556+
557557 /**
558558 * Default per-revision callback, performs the import.
559559 * @param $revision WikiRevision
@@ -892,7 +892,7 @@
893893 }
894894 }
895895 }
896 -
 896+
897897 function in_logitem( $parser, $name, $attribs ) {
898898 $name = $this->stripXmlNamespace($name);
899899 $this->debug( "in_logitem $name" );
@@ -1105,8 +1105,7 @@
11061106 # quicker and sorts out user-agent problems which might
11071107 # otherwise prevent importing from large sites, such
11081108 # as the Wikimedia cluster, etc.
1109 - $req = new HttpRequest( $url, array( 'method' => $method ) );
1110 - $data = $req->doRequest();
 1109+ $data = Http::request( $url, array( 'method' => $method ) );
11111110 if( $data !== false ) {
11121111 $file = tmpfile();
11131112 fwrite( $file, $data );

Status & tagging log