Profile all external HTTP requests from MW
authorChad Horohoe <chadh@wikimedia.org>
Fri, 27 Feb 2015 17:08:06 +0000 (09:08 -0800)
committerChad Horohoe <chadh@wikimedia.org>
Wed, 4 Mar 2015 04:54:30 +0000 (20:54 -0800)
Change-Id: Ie980b080da2ef21ec7d9fc32f1accc55710de140

17 files changed:
includes/Import.php
includes/externalstore/ExternalStoreHttp.php
includes/filerepo/ForeignAPIRepo.php
includes/filerepo/file/File.php
includes/installer/Installer.php
includes/jobqueue/jobs/ThumbnailRenderJob.php
includes/parser/Parser.php
includes/site/MediaWikiSite.php
includes/specials/SpecialUploadStash.php
includes/upload/UploadFromUrl.php
maintenance/benchmarks/bench_HTTP_HTTPS.php
maintenance/findHooks.php
maintenance/importImages.inc
maintenance/importSiteScripts.php
tests/phpunit/includes/HttpTest.php
tests/phpunit/includes/api/ApiLoginTest.php
tests/phpunit/includes/filebackend/FileBackendTest.php

index c036fbe..3ba4306 100644 (file)
@@ -1741,7 +1741,7 @@ class WikiRevision {
 
                // @todo FIXME!
                $src = $this->getSrc();
-               $data = Http::get( $src );
+               $data = Http::get( $src, array(), __METHOD__ );
                if ( !$data ) {
                        wfDebug( "IMPORT: couldn't fetch source $src\n" );
                        fclose( $f );
@@ -1898,7 +1898,7 @@ class ImportStreamSource implements ImportSource {
                # 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, array( 'followRedirects' => true ) );
+               $data = Http::request( $method, $url, array( 'followRedirects' => true ), __METHOD__ );
                if ( $data !== false ) {
                        $file = tmpfile();
                        fwrite( $file, $data );
index 345c17b..00030d8 100644 (file)
@@ -31,7 +31,7 @@ class ExternalStoreHttp extends ExternalStoreMedium {
         * @see ExternalStoreMedium::fetchFromURL()
         */
        public function fetchFromURL( $url ) {
-               return Http::get( $url );
+               return Http::get( $url, array(), __METHOD__ );
        }
 
        /**
index 6924f0a..7ead968 100644 (file)
@@ -514,7 +514,7 @@ class ForeignAPIRepo extends FileRepo {
                        $options['timeout'] = 'default';
                }
 
-               $req = MWHttpRequest::factory( $url, $options );
+               $req = MWHttpRequest::factory( $url, $options, __METHOD__ );
                $req->setUserAgent( ForeignAPIRepo::getUserAgent() );
                $status = $req->execute();
 
index 6ca61b2..2721693 100644 (file)
@@ -2008,7 +2008,7 @@ abstract class File {
                                wfDebug( "miss\n" );
                        }
                        wfDebug( "Fetching shared description from $renderUrl\n" );
-                       $res = Http::get( $renderUrl );
+                       $res = Http::get( $renderUrl, array(), __METHOD__ );
                        if ( $res && $this->repo->descriptionCacheExpiry > 0 ) {
                                $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
                        }
index 91195e9..c29b462 100644 (file)
@@ -1375,7 +1375,7 @@ abstract class Installer {
                                }
 
                                try {
-                                       $text = Http::get( $url . $file, array( 'timeout' => 3 ) );
+                                       $text = Http::get( $url . $file, array( 'timeout' => 3 ), __METHOD__ );
                                } catch ( Exception $e ) {
                                        // Http::get throws with allow_url_fopen = false and no curl extension.
                                        $text = null;
@@ -1723,7 +1723,7 @@ abstract class Installer {
 
                if ( MWHttpRequest::canMakeRequests() ) {
                        $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
-                               array( 'method' => 'POST', 'postData' => $params ) )->execute();
+                               array( 'method' => 'POST', 'postData' => $params ), __METHOD__ )->execute();
                        if ( !$res->isOK() ) {
                                $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
                        }
index dbc4f23..4b5189d 100644 (file)
@@ -92,9 +92,10 @@ class ThumbnailRenderJob extends Job {
 
                wfDebug( __METHOD__ . ": hitting url {$thumbUrl}\n" );
 
-               $request = MWHttpRequest::factory( $thumbUrl, array(
-                       'method' => 'HEAD',
-                       'followRedirects' => true ) );
+               $request = MWHttpRequest::factory( $thumbUrl, 
+                       array( 'method' => 'HEAD', 'followRedirects' => true ),
+                       __METHOD__
+               );
 
                if ( $wgUploadThumbnailRenderHttpCustomHost ) {
                        $request->setHeader( 'Host', $wgUploadThumbnailRenderHttpCustomHost );
index a9b0c82..2f443c0 100644 (file)
@@ -4096,7 +4096,7 @@ class Parser {
                        return $obj->tc_contents;
                }
 
-               $req = MWHttpRequest::factory( $url );
+               $req = MWHttpRequest::factory( $url, array(), __METHOD__ );
                $status = $req->execute(); // Status object
                if ( $status->isOK() ) {
                        $text = $req->getContent();
index 9711f04..739d018 100644 (file)
@@ -137,7 +137,7 @@ class MediaWikiSite extends Site {
 
                        // Go on call the external site
                        // @todo we need a good way to specify a timeout here.
-                       $ret = Http::get( $url );
+                       $ret = Http::get( $url, array(), __METHOD__ );
                }
 
                if ( $ret === false ) {
index 462dbee..4a92bb9 100644 (file)
@@ -252,7 +252,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                        'method' => 'GET',
                        'timeout' => 'default'
                );
-               $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions );
+               $req = MWHttpRequest::factory( $scalerThumbUrl, $httpOptions, __METHOD__ );
                $status = $req->execute();
                if ( !$status->isOK() ) {
                        $errors = $status->getErrorsArray();
index 3d410b1..fc59ace 100644 (file)
@@ -287,7 +287,7 @@ class UploadFromUrl extends UploadBase {
                        'Starting download from "' . $this->mUrl . '" ' .
                                '<' . implode( ',', array_keys( array_filter( $options ) ) ) . '>'
                );
-               $req = MWHttpRequest::factory( $this->mUrl, $options );
+               $req = MWHttpRequest::factory( $this->mUrl, $options, __METHOD__ );
                $req->setCallback( array( $this, 'saveTempFileChunk' ) );
                $status = $req->execute();
 
index bb7499b..1569234 100644 (file)
@@ -46,7 +46,7 @@ class BenchHttpHttps extends Benchmarker {
        }
 
        static function doRequest( $proto ) {
-               Http::get( "$proto://localhost/" );
+               Http::get( "$proto://localhost/", array(), __METHOD__ );
        }
 
        // bench function 1
index d17b06d..5cf4536 100644 (file)
@@ -185,7 +185,7 @@ class FindHooks extends Maintenance {
 
                $retval = array();
                while ( true ) {
-                       $json = Http::get( wfAppendQuery( 'http://www.mediawiki.org/w/api.php', $params ) );
+                       $json = Http::get( wfAppendQuery( 'http://www.mediawiki.org/w/api.php', $params ), array(), __METHOD__ );
                        $data = FormatJson::decode( $json, true );
                        foreach ( $data['query']['categorymembers'] as $page ) {
                                if ( preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $m ) ) {
index b803e3d..4b839a0 100644 (file)
@@ -117,7 +117,7 @@ function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) {
 function getFileCommentFromSourceWiki( $wiki_host, $file ) {
        $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:'
                . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment';
-       $body = Http::get( $url );
+       $body = Http::get( $url, array(), __METHOD__ );
        if ( preg_match( '#<ii comment="([^"]*)" />#', $body, $matches ) == 0 ) {
                return false;
        }
@@ -128,7 +128,7 @@ function getFileCommentFromSourceWiki( $wiki_host, $file ) {
 function getFileUserFromSourceWiki( $wiki_host, $file ) {
        $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:'
                . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user';
-       $body = Http::get( $url );
+       $body = Http::get( $url, array(), __METHOD__ );
        if ( preg_match( '#<ii user="([^"]*)" />#', $body, $matches ) == 0 ) {
                return false;
        }
index e67d077..6566a60 100644 (file)
@@ -59,7 +59,7 @@ class ImportSiteScripts extends Maintenance {
                        $url = wfAppendQuery( $baseUrl, array(
                                'action' => 'raw',
                                'title' => "MediaWiki:{$page}" ) );
-                       $text = Http::get( $url );
+                       $text = Http::get( $url, array(), __METHOD__ );
 
                        $wikiPage = WikiPage::factory( $title );
                        $content = ContentHandler::makeContent( $text, $wikiPage->getTitle() );
@@ -81,7 +81,7 @@ class ImportSiteScripts extends Maintenance {
 
                while ( true ) {
                        $url = wfAppendQuery( $baseUrl, $data );
-                       $strResult = Http::get( $url );
+                       $strResult = Http::get( $url, array(), __METHOD__ );
                        $result = FormatJson::decode( $strResult, true );
 
                        $page = null;
index e3ee705..8a0dff7 100644 (file)
@@ -138,7 +138,7 @@ class HttpTest extends MediaWikiTestCase {
         * HTTP redirects).
         */
        public function testRelativeRedirections() {
-               $h = MWHttpRequestTester::factory( 'http://oldsite/file.ext' );
+               $h = MWHttpRequestTester::factory( 'http://oldsite/file.ext', array(), __METHOD__ );
 
                # Forge a Location header
                $h->setRespHeaders( 'location', array(
index 67a75f3..88a99e9 100644 (file)
@@ -123,7 +123,8 @@ class ApiLoginTest extends ApiTestCase {
                                        "lgname" => $user->username,
                                        "lgpassword" => $user->password
                                )
-                       )
+                       ),
+                       __METHOD__
                );
                $req->execute();
 
index b40d2d2..bfca75a 100644 (file)
@@ -1478,7 +1478,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $url = $this->backend->getFileHttpUrl( array( 'src' => $source ) );
 
                if ( $url !== null ) { // supported
-                       $data = Http::request( "GET", $url );
+                       $data = Http::request( "GET", $url, array(), __METHOD__ );
                        $this->assertEquals( $content, $data,
                                "HTTP GET of URL has right contents ($backendName)." );
                }