Merge "MWHttpRequest: Restore ability to pass null for $options"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 6 Feb 2018 23:48:23 +0000 (23:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 6 Feb 2018 23:48:23 +0000 (23:48 +0000)
includes/http/MWHttpRequest.php
tests/phpunit/includes/http/HttpTest.php

index f13461c..70691b4 100644 (file)
@@ -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 );
index 8ca9f6a..1e685bd 100644 (file)
@@ -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' ) ) {