mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
synced 2024-11-23 13:56:53 +00:00
Replace deprecated Http::get
Bug: T305813 Change-Id: Ief91d92c556244c36dfcec23f770319bd2f2c537
This commit is contained in:
parent
0a06382d72
commit
88aa29cb72
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace CookieWarning;
|
||||
|
||||
use Http;
|
||||
use InvalidArgumentException;
|
||||
use MediaWiki\Http\HttpRequestFactory;
|
||||
use Wikimedia\IPUtils;
|
||||
|
||||
/**
|
||||
|
@ -13,14 +13,19 @@ class HttpGeoLocation implements GeoLocation {
|
|||
private $geoIPServiceURL;
|
||||
private $locatedIPs = [];
|
||||
|
||||
/** @var HttpRequestFactory */
|
||||
private $httpRequestFactory;
|
||||
|
||||
/**
|
||||
* @param string $geoIPServiceURL
|
||||
* @param HttpRequestFactory $httpRequestFactory
|
||||
*/
|
||||
public function __construct( $geoIPServiceURL ) {
|
||||
public function __construct( $geoIPServiceURL, HttpRequestFactory $httpRequestFactory ) {
|
||||
if ( !is_string( $geoIPServiceURL ) || !$geoIPServiceURL ) {
|
||||
throw new InvalidArgumentException( 'The geoIPServiceUL is invalid' );
|
||||
}
|
||||
$this->geoIPServiceURL = $geoIPServiceURL;
|
||||
$this->httpRequestFactory = $httpRequestFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +43,7 @@ class HttpGeoLocation implements GeoLocation {
|
|||
if ( substr( $this->geoIPServiceURL, -1 ) !== '/' ) {
|
||||
$this->geoIPServiceURL .= '/';
|
||||
}
|
||||
$json = Http::get( $this->geoIPServiceURL . $ip, [
|
||||
$json = $this->httpRequestFactory->get( $this->geoIPServiceURL . $ip, [
|
||||
'timeout' => '2',
|
||||
] );
|
||||
if ( !$json ) {
|
||||
|
|
|
@ -18,7 +18,7 @@ return [
|
|||
if ( !is_string( $geoIPServiceURL ) || !$geoIPServiceURL ) {
|
||||
return new NoopGeoLocation();
|
||||
}
|
||||
return new HttpGeoLocation( $geoIPServiceURL );
|
||||
return new HttpGeoLocation( $geoIPServiceURL, $services->getHttpRequestFactory() );
|
||||
},
|
||||
'CookieWarning.Decisions' => static function ( MediaWikiServices $services ) {
|
||||
return new Decisions(
|
||||
|
|
Loading…
Reference in a new issue