Database: Allow selectFieldValues() to accept SQL fragments
[lhc/web/wiklou.git] / includes / libs / MultiHttpClient.php
index 16168e6..dd8772c 100644 (file)
@@ -48,7 +48,7 @@ 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 int */
        protected $connTimeout = 10;
@@ -346,16 +346,7 @@ class MultiHttpClient implements LoggerAwareInterface {
                        // Don't interpret POST parameters starting with '@' as file uploads, because this
                        // makes it impossible to POST plain values starting with '@' (and causes security
                        // issues potentially exposing the contents of local files).
-                       // The PHP manual says this option was introduced in PHP 5.5 defaults to true in PHP 5.6,
-                       // but we support lower versions, and the option doesn't exist in HHVM 5.6.99.
-                       if ( defined( 'CURLOPT_SAFE_UPLOAD' ) ) {
-                               curl_setopt( $ch, CURLOPT_SAFE_UPLOAD, true );
-                       } elseif ( is_array( $req['body'] ) ) {
-                               // In PHP 5.2 and later, '@' is interpreted as a file upload if POSTFIELDS
-                               // is an array, but not if it's a string. So convert $req['body'] to a string
-                               // for safety.
-                               $req['body'] = http_build_query( $req['body'] );
-                       }
+                       curl_setopt( $ch, CURLOPT_SAFE_UPLOAD, true );
                        curl_setopt( $ch, CURLOPT_POSTFIELDS, $req['body'] );
                } else {
                        if ( is_resource( $req['body'] ) || $req['body'] !== '' ) {
@@ -421,9 +412,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 );