From 8f416baead93a48e5799e44b8bd2e2c4859f4e04 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 14 Sep 2007 13:18:58 +0200 Subject: auf Version 1.11 aktualisiert; Login-Bug behoben --- includes/SpecialImport.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'includes/SpecialImport.php') diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index c7b861d0..ad5d8e64 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -85,7 +85,7 @@ function wfSpecialImport( $page = '' ) { } } - $action = $wgTitle->escapeLocalUrl( 'action=submit' ); + $action = $wgTitle->getLocalUrl( 'action=submit' ); if( $wgUser->isAllowed( 'importupload' ) ) { $wgOut->addWikiText( wfMsg( "importtext" ) ); @@ -209,6 +209,9 @@ class ImportReporter { $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleId(), $comment, true ); $nullRevision->insertOn( $dbw ); + # Update page record + $article = new Article( $title ); + $article->updateRevisionOn( $dbw, $nullRevision ); } } @@ -857,13 +860,22 @@ class ImportStreamSource { } } - function newFromURL( $url ) { + function newFromURL( $url, $method = 'GET' ) { 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::request( $method, $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 ) { @@ -873,10 +885,11 @@ class ImportStreamSource { } else { $params = $history ? 'history=1' : ''; $url = $link->getFullUrl( $params ); - return ImportStreamSource::newFromURL( $url ); + # For interwikis, use POST to avoid redirects. + return ImportStreamSource::newFromURL( $url, "POST" ); } } } -?> + -- cgit v1.2.3-54-g00ecf