r50812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50811‎ | r50812 | r50813 >
Date:07:36, 20 May 2009
Author:thedevilonline
Status:deferred
Tags:
Comment:
- Standardized the code to get the contents of an external file using Http:get (Ty Nikerabbit)
Modified paths:
  • /trunk/extensions/LocalisationUpdate/KNOWN_ISSUES.txt (modified) (history)
  • /trunk/extensions/LocalisationUpdate/LocalisationUpdate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.php
@@ -1,8 +1,6 @@
22 <?php
33 /*
44 KNOWN ISSUES:
5 -- If no cURL is supported anf url_fopen[1] is disabled the
6 - extension will not update
75 - Only works with SVN revision 50605 or later of the
86 Mediawiki core
97 */
@@ -201,12 +199,9 @@
202200 $langcode = strtolower($m[1]);
203201
204202 //use cURL to get the SVN contents
205 - if(is_callable("curl_init") && preg_match("/^http/",$basefile)) {
206 - $ch = curl_init();
207 - curl_setopt($ch,CURLOPT_HEADER,0);
208 - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
209 - curl_setopt($ch,CURLOPT_URL,$basefile);
210 - if(!$basefilecontents = curl_exec($ch)) {
 203+ if(preg_match("/^http/",$basefile)) {
 204+ $basefilecontents = Http::get($basefile);
 205+ if(empty($basefilecontents)) {
211206 myLog("Can't get the contents of ".$basefile." (curl)");
212207 return array();
213208 }
@@ -244,12 +239,9 @@
245240 eval($basefilecontents);
246241
247242 //use cURL to get the contents
248 - if(is_callable("curl_init") && preg_match("/^http/",$comparefile)) {
249 - $ch = curl_init();
250 - curl_setopt($ch,CURLOPT_HEADER,0);
251 - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
252 - curl_setopt($ch,CURLOPT_URL,$comparefile);
253 - if(!$comparefilecontents = curl_exec($ch)) {
 243+ if(preg_match("/^http/",$comparefile)) {
 244+ $comparefilecontents = Http::get($comparefile);
 245+ if(empty($comparefilecontents)) {
254246 myLog("Can't get the contents of ".$comparefile." (curl)");
255247 return array();
256248 }
@@ -366,13 +358,9 @@
367359 $compare_messages = array();
368360 $base_messages = array();
369361
370 - //use cURL to get the file contents
371 - if(is_callable("curl_init") && preg_match("/^http/",$basefile)) {
372 - $ch = curl_init();
373 - curl_setopt($ch,CURLOPT_HEADER,0);
374 - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
375 - curl_setopt($ch,CURLOPT_URL,$basefile);
376 - if(!$basefilecontents = curl_exec($ch)) {
 362+ if(preg_match("/^http/",$basefile)) {
 363+ $basefilecontents = Http::get($basefile);
 364+ if(empty($basefilecontents)) {
377365 myLog("Can't get the contents of ".$basefile." (curl)");
378366 return 0;
379367 }
@@ -411,12 +399,9 @@
412400 eval($basefilecontents);
413401
414402 //Use cURL when available
415 - if(is_callable("curl_init") && preg_match("/^http/",$comparefile)) {
416 - $ch = curl_init();
417 - curl_setopt($ch,CURLOPT_HEADER,0);
418 - curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
419 - curl_setopt($ch,CURLOPT_URL,$comparefile);
420 - if(!$comparefilecontents = curl_exec($ch)) {
 403+ if(preg_match("/^http/",$comparefile)) {
 404+ $comparefilecontents = Http::get($comparefile);
 405+ if(empty($comparefilecontents)) {
421406 myLog("Can't get the contents of ".$comparefile." (curl)");
422407 return 0;
423408 }
Index: trunk/extensions/LocalisationUpdate/KNOWN_ISSUES.txt
@@ -1,4 +1,2 @@
2 -- If no cURL is supported and url_fopen[1] is disabled the
3 - extension will not update
42 - Only works with SVN revision 50605 or later of the
53 MediaWiki core

Status & tagging log