From: Kunal Mehta Date: Tue, 6 Feb 2018 21:05:02 +0000 (-0800) Subject: MWHttpRequest: Restore ability to pass null for $options X-Git-Tag: 1.31.0-rc.0~681^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=449e31a179e337edbc205262bb29476c901d19c5;ds=sidebyside MWHttpRequest: Restore ability to pass null for $options Prior to 3de744597e34, it was possible to pass `null` for $options. Restore that by setting the default type to be null, and explicitly document that null is a supported value in the doc block. Also update the signature of MWHttpRequestTester to match. Change-Id: I74d586afa5527e0a30ea99f3989f4dd12fa9fea1 --- diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php index f13461c797..70691b4cff 100644 --- a/includes/http/MWHttpRequest.php +++ b/includes/http/MWHttpRequest.php @@ -175,13 +175,16 @@ abstract class MWHttpRequest implements LoggerAwareInterface { * Generate a new request object * Deprecated: @see HttpRequestFactory::create * @param string $url Url to use - * @param array $options (optional) extra params to pass (see Http::request()) + * @param array|null $options (optional) extra params to pass (see Http::request()) * @param string $caller The method making this request, for profiling * @throws DomainException * @return MWHttpRequest * @see MWHttpRequest::__construct */ - public static function factory( $url, array $options = [], $caller = __METHOD__ ) { + public static function factory( $url, array $options = null, $caller = __METHOD__ ) { + if ( $options === null ) { + $options = []; + } return \MediaWiki\MediaWikiServices::getInstance() ->getHttpRequestFactory() ->create( $url, $options, $caller ); diff --git a/tests/phpunit/includes/http/HttpTest.php b/tests/phpunit/includes/http/HttpTest.php index 8ca9f6a268..1e685bd500 100644 --- a/tests/phpunit/includes/http/HttpTest.php +++ b/tests/phpunit/includes/http/HttpTest.php @@ -510,7 +510,7 @@ class HttpTest extends MediaWikiTestCase { class MWHttpRequestTester extends MWHttpRequest { // function derived from the MWHttpRequest factory function but // returns appropriate tester class here - public static function factory( $url, $options = null, $caller = __METHOD__ ) { + public static function factory( $url, array $options = null, $caller = __METHOD__ ) { if ( !Http::$httpEngine ) { Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php'; } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) {