r76566 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76565‎ | r76566 | r76567 >
Date:07:32, 12 November 2010
Author:bawolff
Status:ok
Tags:
Comment:
(Bug 25872) Rename HttpRequest class to MWHttpRequest to avoid conflict with php extension.

This also keeps the old HttpRequest class name around, so it should not break backwards compatability.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/HttpFunctions.old.php (added) (history)
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIRepo.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadFromUrl.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/HttpTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/HttpTest.php
@@ -76,7 +76,7 @@
7777 function testInstantiation() {
7878 Http::$httpEngine = false;
7979
80 - $r = HttpRequest::factory( "http://www.example.com/" );
 80+ $r = MWHttpRequest::factory( "http://www.example.com/" );
8181 if ( self::$has_curl ) {
8282 $this->assertThat( $r, $this->isInstanceOf( 'CurlHttpRequest' ) );
8383 } else {
@@ -88,7 +88,7 @@
8989 $this->setExpectedException( 'MWException' );
9090 }
9191 Http::$httpEngine = 'php';
92 - $r = HttpRequest::factory( "http://www.example.com/" );
 92+ $r = MWHttpRequest::factory( "http://www.example.com/" );
9393 $this->assertThat( $r, $this->isInstanceOf( 'PhpHttpRequest' ) );
9494 unset( $r );
9595
@@ -96,7 +96,7 @@
9797 $this->setExpectedException( 'MWException' );
9898 }
9999 Http::$httpEngine = 'curl';
100 - $r = HttpRequest::factory( "http://www.example.com/" );
 100+ $r = MWHttpRequest::factory( "http://www.example.com/" );
101101 if ( self::$has_curl ) {
102102 $this->assertThat( $r, $this->isInstanceOf( 'CurlHttpRequest' ) );
103103 }
@@ -117,7 +117,7 @@
118118 $this->assertFalse( $r, "False on 404s" );
119119
120120
121 - $r = HttpRequest::factory( "http://www.example.com/this-file-does-not-exist" );
 121+ $r = MWHttpRequest::factory( "http://www.example.com/this-file-does-not-exist" );
122122 $er = $r->execute();
123123 if ( is_a( $r, 'PhpHttpRequest' ) && version_compare( '5.2.10', phpversion(), '>' ) ) {
124124 $this->assertRegexp( "/HTTP request failed/", $er->getWikiText() );
@@ -532,7 +532,7 @@
533533 }
534534
535535 function runCookieRequests() {
536 - $r = HttpRequest::factory( "http://www.php.net/manual", array( 'followRedirects' => true ) );
 536+ $r = MWHttpRequest::factory( "http://www.php.net/manual", array( 'followRedirects' => true ) );
537537 $r->execute();
538538
539539 $jar = $r->getCookieJar();
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
@@ -171,7 +171,7 @@
172172 if ( !isset( $wgServer ) ) {
173173 $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
174174 }
175 - $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
 175+ $req = MWHttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
176176 array( "method" => "POST",
177177 "postData" => array(
178178 "lgname" => self::$user->userName,
@@ -214,7 +214,7 @@
215215 if ( $wgServer == "http://localhost" ) {
216216 $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
217217 }
218 - $req = HttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&" .
 218+ $req = MWHttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&" .
219219 "titles=Main%20Page&rvprop=timestamp|user|comment|content" );
220220 $req->setCookieJar( $cj );
221221 $req->execute();
Index: trunk/phase3/includes/upload/UploadFromUrl.php
@@ -100,7 +100,7 @@
101101 /**
102102 * Save the result of a HTTP request to the temporary file
103103 *
104 - * @param $req HttpRequest
 104+ * @param $req MWHttpRequest
105105 * @return Status
106106 */
107107 private function saveTempFile( $req ) {
@@ -120,7 +120,7 @@
121121 * size and set $mRemoveTempFile to true.
122122 */
123123 protected function reallyFetchFile() {
124 - $req = HttpRequest::factory( $this->mUrl );
 124+ $req = MWHttpRequest::factory( $this->mUrl );
125125 $status = $req->execute();
126126
127127 if ( !$status->isOk() ) {
Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php
@@ -362,7 +362,7 @@
363363 $options['timeout'] = 'default';
364364 }
365365
366 - $req = HttpRequest::factory( $url, $options );
 366+ $req = MWHttpRequest::factory( $url, $options );
367367 $req->setUserAgent( ForeignAPIRepo::getUserAgent() );
368368 $status = $req->execute();
369369
Index: trunk/phase3/includes/AutoLoader.php
@@ -125,7 +125,7 @@
126126 'HTMLRadioField' => 'includes/HTMLForm.php',
127127 'HTMLInfoField' => 'includes/HTMLForm.php',
128128 'Http' => 'includes/HttpFunctions.php',
129 - 'HttpRequest' => 'includes/HttpFunctions.php',
 129+ 'HttpRequest' => 'includes/HttpFunctions.old.php',
130130 'ImageGallery' => 'includes/ImageGallery.php',
131131 'ImageHistoryList' => 'includes/ImagePage.php',
132132 'ImageHistoryPseudoPager' => 'includes/ImagePage.php',
@@ -167,6 +167,7 @@
168168 'MessageCache' => 'includes/MessageCache.php',
169169 'MimeMagic' => 'includes/MimeMagic.php',
170170 'MWException' => 'includes/Exception.php',
 171+ 'MWHttpRequest' => 'includes/HttpFunctions.php',
171172 'MWMemcached' => 'includes/memcached-client.php',
172173 'MWNamespace' => 'includes/Namespace.php',
173174 'OldChangesList' => 'includes/ChangesList.php',
Index: trunk/phase3/includes/HttpFunctions.old.php
@@ -0,0 +1,24 @@
 2+<?php
 3+
 4+/**
 5+ * HttpRequest was renamed to MWHttpRequest in order
 6+ * to prevent conflicts with PHP's HTTP extension
 7+ * which also defines an HttpRequest class.
 8+ * http://www.php.net/manual/en/class.httprequest.php
 9+ *
 10+ * This is for backwards compatibility.
 11+ */
 12+
 13+class HttpRequest extends MWHttpRequest { }
 14+<?php
 15+
 16+/**
 17+ * HttpRequest was renamed to MWHttpRequest in order
 18+ * to prevent conflicts with PHP's HTTP extension
 19+ * which also defines an HttpRequest class.
 20+ * http://www.php.net/manual/en/class.httprequest.php
 21+ *
 22+ * This is for backwards compatibility.
 23+ */
 24+
 25+class HttpRequest extends MWHttpRequest { }
Index: trunk/phase3/includes/HttpFunctions.php
@@ -15,7 +15,7 @@
1616 *
1717 * @param $method String: HTTP method. Usually GET/POST
1818 * @param $url String: full URL to act on
19 - * @param $options Array: options to pass to HttpRequest object.
 19+ * @param $options Array: options to pass to MWHttpRequest object.
2020 * Possible keys for the array:
2121 * - timeout Timeout length in seconds
2222 * - postData An array of key-value pairs or a url-encoded form data
@@ -40,7 +40,7 @@
4141 $options['timeout'] = 'default';
4242 }
4343
44 - $req = HttpRequest::factory( $url, $options );
 44+ $req = MWHttpRequest::factory( $url, $options );
4545 $status = $req->execute();
4646
4747 if ( $status->isOK() ) {
@@ -133,8 +133,11 @@
134134 /**
135135 * This wrapper class will call out to curl (if available) or fallback
136136 * to regular PHP if necessary for handling internal HTTP requests.
 137+ *
 138+ * Renamed from HttpRequest to MWHttpRequst to avoid conflict with
 139+ * php's HTTP extension.
137140 */
138 -class HttpRequest {
 141+class MWHttpRequest {
139142 protected $content;
140143 protected $timeout = 'default';
141144 protected $headersOnly = null;
@@ -195,7 +198,7 @@
196199
197200 /**
198201 * Generate a new request object
199 - * @see HttpRequest::__construct
 202+ * @see MWHttpRequest::__construct
200203 */
201204 public static function factory( $url, $options = null ) {
202205 if ( !Http::$httpEngine ) {
@@ -477,7 +480,7 @@
478481 }
479482
480483 /**
481 - * Tells the HttpRequest object to use this pre-loaded CookieJar.
 484+ * Tells the MWHttpRequest object to use this pre-loaded CookieJar.
482485 *
483486 * @param $jar CookieJar
484487 */
@@ -792,9 +795,9 @@
793796 }
794797
795798 /**
796 - * HttpRequest implemented using internal curl compiled into PHP
 799+ * MWHttpRequest implemented using internal curl compiled into PHP
797800 */
798 -class CurlHttpRequest extends HttpRequest {
 801+class CurlHttpRequest extends MWHttpRequest {
799802 static $curlMessageMap = array(
800803 6 => 'http-host-unreachable',
801804 28 => 'http-timed-out'
@@ -907,7 +910,7 @@
908911 }
909912 }
910913
911 -class PhpHttpRequest extends HttpRequest {
 914+class PhpHttpRequest extends MWHttpRequest {
912915 protected function urlToTcp( $url ) {
913916 $parsedUrl = parse_url( $url );
914917
Index: trunk/phase3/RELEASE-NOTES
@@ -421,6 +421,8 @@
422422 some cases
423423 * (bug 25670) wfFindFile() now checks the namespace of the given title, only
424424 "File" and "Media" are allowed now
 425+* (bug 25872) Rename the HttpRequest class to MWHttpRequest to avoid conflict
 426+ with php extension that defines same class.
425427
426428 === API changes in 1.17 ===
427429 * (bug 22738) Allow filtering by action type on query=logevent.

Follow-up revisions

RevisionCommit summaryAuthorDate
r76567Follow up r76566 (Bug 25872) - rename HttpRequest class to avoid conflicts wi...bawolff07:47, 12 November 2010
r76575Followup r76566...reedy14:20, 12 November 2010

Status & tagging log