Merge "Add SPARQL client to core"
[lhc/web/wiklou.git] / includes / libs / MultiHttpClient.php
index 4f6195c..053a5ff 100644 (file)
@@ -48,15 +48,15 @@ use Psr\Log\NullLogger;
 class MultiHttpClient implements LoggerAwareInterface {
        /** @var resource */
        protected $multiHandle = null; // curl_multi handle
-       /** @var string|null SSL certificates path  */
+       /** @var string|null SSL certificates path */
        protected $caBundlePath;
-       /** @var integer */
+       /** @var int */
        protected $connTimeout = 10;
-       /** @var integer */
+       /** @var int */
        protected $reqTimeout = 300;
        /** @var bool */
        protected $usePipelining = false;
-       /** @var integer */
+       /** @var int */
        protected $maxConnsPerHost = 50;
        /** @var string|null proxy */
        protected $proxy;
@@ -421,9 +421,14 @@ class MultiHttpClient implements LoggerAwareInterface {
 
        /**
         * @return resource
+        * @throws Exception
         */
        protected function getCurlMulti() {
                if ( !$this->multiHandle ) {
+                       if ( !function_exists( 'curl_multi_init' ) ) {
+                               throw new Exception( "PHP cURL extension missing. " .
+                                                                        "Check https://www.mediawiki.org/wiki/Manual:CURL" );
+                       }
                        $cmh = curl_multi_init();
                        curl_multi_setopt( $cmh, CURLMOPT_PIPELINING, (int)$this->usePipelining );
                        curl_multi_setopt( $cmh, CURLMOPT_MAXCONNECTS, (int)$this->maxConnsPerHost );
@@ -435,7 +440,7 @@ class MultiHttpClient implements LoggerAwareInterface {
        /**
         * Register a logger
         *
-        * @param LoggerInterface
+        * @param LoggerInterface $logger
         */
        public function setLogger( LoggerInterface $logger ) {
                $this->logger = $logger;