This also keeps the old HttpRequest class name around, so it should not break backwards compatability.
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.
'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',
'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',
--- /dev/null
+<?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 { }
*
* @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
$options['timeout'] = 'default';
}
- $req = HttpRequest::factory( $url, $options );
+ $req = MWHttpRequest::factory( $url, $options );
$status = $req->execute();
if ( $status->isOK() ) {
/**
* 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;
/**
* Generate a new request object
- * @see HttpRequest::__construct
+ * @see MWHttpRequest::__construct
*/
public static function factory( $url, $options = null ) {
if ( !Http::$httpEngine ) {
}
/**
- * Tells the HttpRequest object to use this pre-loaded CookieJar.
+ * Tells the MWHttpRequest object to use this pre-loaded CookieJar.
*
* @param $jar 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'
}
}
-class PhpHttpRequest extends HttpRequest {
+class PhpHttpRequest extends MWHttpRequest {
protected function urlToTcp( $url ) {
$parsedUrl = parse_url( $url );
$options['timeout'] = 'default';
}
- $req = HttpRequest::factory( $url, $options );
+ $req = MWHttpRequest::factory( $url, $options );
$req->setUserAgent( ForeignAPIRepo::getUserAgent() );
$status = $req->execute();
/**
* Save the result of a HTTP request to the temporary file
*
- * @param $req HttpRequest
+ * @param $req MWHttpRequest
* @return Status
*/
private function saveTempFile( $req ) {
* 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() ) {
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 {
$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 );
$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' ) );
}
$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() );
}
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();
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,
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();