Merge "Skin: Use WANObjectCache for sitenotice caching"
[lhc/web/wiklou.git] / includes / site / MediaWikiPageNameNormalizer.php
index 2f71736..c4e490a 100644 (file)
@@ -34,6 +34,22 @@ use UtfNormal\Validator;
  */
 class MediaWikiPageNameNormalizer {
 
+       /**
+        * @var Http
+        */
+       private $http;
+
+       /**
+        * @param Http|null $http
+        */
+       public function __construct( Http $http = null ) {
+               if ( !$http ) {
+                       $http = new Http();
+               }
+
+               $this->http = $http;
+       }
+
        /**
         * Returns the normalized form of the given page title, using the
         * normalization rules of the given site. If the given title is a redirect,
@@ -53,7 +69,6 @@ class MediaWikiPageNameNormalizer {
         * @throws \MWException
         */
        public function normalizePageName( $pageName, $apiUrl ) {
-
                // Check if we have strings as arguments.
                if ( !is_string( $pageName ) ) {
                        throw new \MWException( '$pageName must be a string' );
@@ -85,7 +100,7 @@ class MediaWikiPageNameNormalizer {
 
                // Go on call the external site
                // @todo we need a good way to specify a timeout here.
-               $ret = Http::get( $url, [], __METHOD__ );
+               $ret = $this->http->get( $url, [], __METHOD__ );
 
                if ( $ret === false ) {
                        wfDebugLog( "MediaWikiSite", "call to external site failed: $url" );