X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=blobdiff_plain;f=includes%2Fhttp%2FMWHttpRequest.php;h=fff72ec09febceaf274186dae8f557d00036bdeb;hb=ebbfe592fe02e38ab2201c0141e7468284e8ff68;hp=0f0118ce004cc81dcf19a9d4ed9fde7400ce0645;hpb=0a176a1e01d67d6a15dc9435a57018d5082e1b35;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php index 0f0118ce00..fff72ec09f 100644 --- a/includes/http/MWHttpRequest.php +++ b/includes/http/MWHttpRequest.php @@ -18,7 +18,6 @@ * @file */ -use MediaWiki\Logger\LoggerFactory; use Psr\Log\LoggerInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\NullLogger; @@ -30,7 +29,7 @@ use Psr\Log\NullLogger; * Renamed from HttpRequest to MWHttpRequest to avoid conflict with * PHP's HTTP extension. */ -class MWHttpRequest implements LoggerAwareInterface { +abstract class MWHttpRequest implements LoggerAwareInterface { const SUPPORTS_FILE_POSTS = false; /** @@ -90,8 +89,8 @@ class MWHttpRequest implements LoggerAwareInterface { * @param string $caller The method making this request, for profiling * @param Profiler $profiler An instance of the profiler for profiling, or null */ - protected function __construct( - $url, $options = [], $caller = __METHOD__, $profiler = null + public function __construct( + $url, array $options = [], $caller = __METHOD__, $profiler = null ) { global $wgHTTPTimeout, $wgHTTPConnectTimeout; @@ -174,44 +173,18 @@ 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 string $caller The method making this request, for profiling * @throws DomainException - * @return CurlHttpRequest|PhpHttpRequest + * @return MWHttpRequest * @see MWHttpRequest::__construct */ public static function factory( $url, $options = null, $caller = __METHOD__ ) { - if ( !Http::$httpEngine ) { - Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php'; - } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) { - throw new DomainException( __METHOD__ . ': curl (http://php.net/curl) is not installed, but' . - ' Http::$httpEngine is set to "curl"' ); - } - - if ( !is_array( $options ) ) { - $options = []; - } - - if ( !isset( $options['logger'] ) ) { - $options['logger'] = LoggerFactory::getInstance( 'http' ); - } - - switch ( Http::$httpEngine ) { - case 'curl': - return new CurlHttpRequest( $url, $options, $caller, Profiler::instance() ); - case 'php': - if ( !wfIniGetBool( 'allow_url_fopen' ) ) { - throw new DomainException( __METHOD__ . ': allow_url_fopen ' . - 'needs to be enabled for pure PHP http requests to ' . - 'work. If possible, curl should be used instead. See ' . - 'http://php.net/curl.' - ); - } - return new PhpHttpRequest( $url, $options, $caller, Profiler::instance() ); - default: - throw new DomainException( __METHOD__ . ': The setting of Http::$httpEngine is not valid.' ); - } + return \MediaWiki\MediaWikiServices::getInstance() + ->getHttpRequestFactory() + ->create( $url, $options, $caller ); } /**