(Bug 25872) Rename HttpRequest class to MWHttpRequest to avoid conflict with php...
authorBrian Wolff <bawolff@users.mediawiki.org>
Fri, 12 Nov 2010 07:32:09 +0000 (07:32 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Fri, 12 Nov 2010 07:32:09 +0000 (07:32 +0000)
This also keeps the old HttpRequest class name around, so it should not break backwards compatability.

RELEASE-NOTES
includes/AutoLoader.php
includes/HttpFunctions.old.php [new file with mode: 0644]
includes/HttpFunctions.php
includes/filerepo/ForeignAPIRepo.php
includes/upload/UploadFromUrl.php
maintenance/tests/phpunit/includes/HttpTest.php
maintenance/tests/phpunit/includes/api/ApiTest.php

index ec86c60..5084728 100644 (file)
@@ -421,6 +421,8 @@ LocalSettings.php. The specific bugs are listed below in the general notes.
   some cases
 * (bug 25670) wfFindFile() now checks the namespace of the given title, only
   "File" and "Media" are allowed now
+* (bug 25872) Rename the HttpRequest class to MWHttpRequest to avoid conflict
+  with php extension that defines same class.
 
 === API changes in 1.17 ===
 * (bug 22738) Allow filtering by action type on query=logevent.
index 6a6ed8d..417c74d 100644 (file)
@@ -125,7 +125,7 @@ $wgAutoloadLocalClasses = array(
        'HTMLRadioField' => 'includes/HTMLForm.php',
        'HTMLInfoField' => 'includes/HTMLForm.php',
        'Http' => 'includes/HttpFunctions.php',
-       'HttpRequest' => 'includes/HttpFunctions.php',
+       'HttpRequest' => 'includes/HttpFunctions.old.php',
        'ImageGallery' => 'includes/ImageGallery.php',
        'ImageHistoryList' => 'includes/ImagePage.php',
        'ImageHistoryPseudoPager' => 'includes/ImagePage.php',
@@ -167,6 +167,7 @@ $wgAutoloadLocalClasses = array(
        'MessageCache' => 'includes/MessageCache.php',
        'MimeMagic' => 'includes/MimeMagic.php',
        'MWException' => 'includes/Exception.php',
+       'MWHttpRequest' => 'includes/HttpFunctions.php',
        'MWMemcached' => 'includes/memcached-client.php',
        'MWNamespace' => 'includes/Namespace.php',
        'OldChangesList' => 'includes/ChangesList.php',
diff --git a/includes/HttpFunctions.old.php b/includes/HttpFunctions.old.php
new file mode 100644 (file)
index 0000000..166d2cd
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+/**
+ * HttpRequest was renamed to MWHttpRequest in order
+ * to prevent conflicts with PHP's HTTP extension
+ * which also defines an HttpRequest class.
+ * http://www.php.net/manual/en/class.httprequest.php
+ *
+ * This is for backwards compatibility.
+ */
+
+class HttpRequest extends MWHttpRequest { }
+<?php
+
+/**
+ * HttpRequest was renamed to MWHttpRequest in order
+ * to prevent conflicts with PHP's HTTP extension
+ * which also defines an HttpRequest class.
+ * http://www.php.net/manual/en/class.httprequest.php
+ *
+ * This is for backwards compatibility.
+ */
+
+class HttpRequest extends MWHttpRequest { }
index ad1f30a..042ee86 100644 (file)
@@ -15,7 +15,7 @@ class Http {
         *
         * @param $method String: HTTP method. Usually GET/POST
         * @param $url String: full URL to act on
-        * @param $options Array: options to pass to HttpRequest object.
+        * @param $options Array: options to pass to MWHttpRequest object.
         *      Possible keys for the array:
         *    - timeout             Timeout length in seconds
         *    - postData            An array of key-value pairs or a url-encoded form data
@@ -40,7 +40,7 @@ class Http {
                        $options['timeout'] = 'default';
                }
 
-               $req = HttpRequest::factory( $url, $options );
+               $req = MWHttpRequest::factory( $url, $options );
                $status = $req->execute();
 
                if ( $status->isOK() ) {
@@ -133,8 +133,11 @@ class Http {
 /**
  * This wrapper class will call out to curl (if available) or fallback
  * to regular PHP if necessary for handling internal HTTP requests.
+ *
+ * Renamed from HttpRequest to MWHttpRequst to avoid conflict with
+ * php's HTTP extension.
  */
-class HttpRequest {
+class MWHttpRequest {
        protected $content;
        protected $timeout = 'default';
        protected $headersOnly = null;
@@ -195,7 +198,7 @@ class HttpRequest {
 
        /**
         * Generate a new request object
-        * @see HttpRequest::__construct
+        * @see MWHttpRequest::__construct
         */
        public static function factory( $url, $options = null ) {
                if ( !Http::$httpEngine ) {
@@ -477,7 +480,7 @@ class HttpRequest {
        }
 
        /**
-        * Tells the HttpRequest object to use this pre-loaded CookieJar.
+        * Tells the MWHttpRequest object to use this pre-loaded CookieJar.
         *
         * @param $jar CookieJar
         */
@@ -792,9 +795,9 @@ class CookieJar {
 }
 
 /**
- * HttpRequest implemented using internal curl compiled into PHP
+ * MWHttpRequest implemented using internal curl compiled into PHP
  */
-class CurlHttpRequest extends HttpRequest {
+class CurlHttpRequest extends MWHttpRequest {
        static $curlMessageMap = array(
                6 => 'http-host-unreachable',
                28 => 'http-timed-out'
@@ -907,7 +910,7 @@ class CurlHttpRequest extends HttpRequest {
        }
 }
 
-class PhpHttpRequest extends HttpRequest {
+class PhpHttpRequest extends MWHttpRequest {
        protected function urlToTcp( $url ) {
                $parsedUrl = parse_url( $url );
 
index 47bfaa2..ef17596 100644 (file)
@@ -362,7 +362,7 @@ class ForeignAPIRepo extends FileRepo {
                        $options['timeout'] = 'default';
                }
 
-               $req = HttpRequest::factory( $url, $options );
+               $req = MWHttpRequest::factory( $url, $options );
                $req->setUserAgent( ForeignAPIRepo::getUserAgent() );
                $status = $req->execute();
 
index 42b3827..99f6c2a 100644 (file)
@@ -100,7 +100,7 @@ class UploadFromUrl extends UploadBase {
        /**
         * Save the result of a HTTP request to the temporary file
         * 
-        * @param $req HttpRequest 
+        * @param $req MWHttpRequest 
         * @return Status
         */
        private function saveTempFile( $req ) {
@@ -120,7 +120,7 @@ class UploadFromUrl extends UploadBase {
         * size and set $mRemoveTempFile to true.
         */
        protected function reallyFetchFile() {
-               $req = HttpRequest::factory( $this->mUrl );
+               $req = MWHttpRequest::factory( $this->mUrl );
                $status = $req->execute();
 
                if ( !$status->isOk() ) {
index 994a489..b11ce4c 100644 (file)
@@ -76,7 +76,7 @@ class HttpTest extends PHPUnit_Framework_TestCase {
        function testInstantiation() {
                Http::$httpEngine = false;
 
-               $r = HttpRequest::factory( "http://www.example.com/" );
+               $r = MWHttpRequest::factory( "http://www.example.com/" );
                if ( self::$has_curl ) {
                        $this->assertThat( $r, $this->isInstanceOf( 'CurlHttpRequest' ) );
                } else {
@@ -88,7 +88,7 @@ class HttpTest extends PHPUnit_Framework_TestCase {
                        $this->setExpectedException( 'MWException' );
                }
                Http::$httpEngine = 'php';
-               $r = HttpRequest::factory( "http://www.example.com/" );
+               $r = MWHttpRequest::factory( "http://www.example.com/" );
                $this->assertThat( $r, $this->isInstanceOf( 'PhpHttpRequest' ) );
                unset( $r );
 
@@ -96,7 +96,7 @@ class HttpTest extends PHPUnit_Framework_TestCase {
                        $this->setExpectedException( 'MWException' );
                }
                Http::$httpEngine = 'curl';
-               $r = HttpRequest::factory( "http://www.example.com/" );
+               $r = MWHttpRequest::factory( "http://www.example.com/" );
                if ( self::$has_curl ) {
                        $this->assertThat( $r, $this->isInstanceOf( 'CurlHttpRequest' ) );
                }
@@ -117,7 +117,7 @@ class HttpTest extends PHPUnit_Framework_TestCase {
                $this->assertFalse( $r, "False on 404s" );
 
 
-               $r = HttpRequest::factory( "http://www.example.com/this-file-does-not-exist" );
+               $r = MWHttpRequest::factory( "http://www.example.com/this-file-does-not-exist" );
                $er = $r->execute();
                if ( is_a( $r, 'PhpHttpRequest' ) && version_compare( '5.2.10', phpversion(), '>' ) ) {
                        $this->assertRegexp( "/HTTP request failed/", $er->getWikiText() );
@@ -532,7 +532,7 @@ class HttpTest extends PHPUnit_Framework_TestCase {
        }
 
        function runCookieRequests() {
-               $r = HttpRequest::factory( "http://www.php.net/manual", array( 'followRedirects' => true ) );
+               $r = MWHttpRequest::factory( "http://www.php.net/manual", array( 'followRedirects' => true ) );
                $r->execute();
 
                $jar = $r->getCookieJar();
index 2f1deec..d953cbd 100644 (file)
@@ -171,7 +171,7 @@ class ApiTest extends ApiTestSetup {
                if ( !isset( $wgServer ) ) {
                        $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
                }
-               $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
+               $req = MWHttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
                        array( "method" => "POST",
                                "postData" => array(
                                "lgname" => self::$user->userName,
@@ -214,7 +214,7 @@ class ApiTest extends ApiTestSetup {
                if ( $wgServer == "http://localhost" ) {
                        $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
                }
-               $req = HttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&" .
+               $req = MWHttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&" .
                                                                         "titles=Main%20Page&rvprop=timestamp|user|comment|content" );
                $req->setCookieJar( $cj );
                $req->execute();