Use the standard HTTP fetch functions when retrieving remote wiki pages through trans...
authorRob Church <robchurch@users.mediawiki.org>
Sun, 6 May 2007 13:06:21 +0000 (13:06 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sun, 6 May 2007 13:06:21 +0000 (13:06 +0000)
RELEASE-NOTES
includes/SpecialImport.php

index 367afb3..fd1d8a9 100644 (file)
@@ -38,6 +38,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   (cosmetic change, no vulnerabilities existed)
 * Subtitle success message when unblocking a block ID instead of a pseudo link
   like [[User:#123|#123]]
+* Use the standard HTTP fetch functions when retrieving remote wiki pages
+  through transwiki, so we can take advantage of cURL goodies if available
 
 == Maintenance script changes since 1.10 ==
 
index c7b861d..10e734c 100644 (file)
@@ -859,11 +859,20 @@ class ImportStreamSource {
 
        function newFromURL( $url ) {
                wfDebug( __METHOD__ . ": opening $url\n" );
-               # fopen-wrappers are normally turned off for security.
-               ini_set( "allow_url_fopen", true );
-               $ret = ImportStreamSource::newFromFile( $url );
-               ini_set( "allow_url_fopen", false );
-               return $ret;
+               # Use the standard HTTP fetch function; it times out
+               # quicker and sorts out user-agent problems which might
+               # otherwise prevent importing from large sites, such
+               # as the Wikimedia cluster, etc.
+               $data = Http::get( $url );
+               if( $data !== false ) {
+                       $file = tmpfile();
+                       fwrite( $file, $data );
+                       fflush( $file );
+                       fseek( $file, 0 );
+                       return new ImportStreamSource( $file );
+               } else {
+                       return new WikiErrorMsg( 'importcantopen' );
+               }
        }
 
        public static function newFromInterwiki( $interwiki, $page, $history=false ) {