Throw exception if php-curl is missing
authorMoritz Schubotz (physikerwelt) <wiki@physikerwelt.de>
Fri, 2 Feb 2018 15:37:00 +0000 (16:37 +0100)
committerMoritz Schubotz (physikerwelt) <wiki@physikerwelt.de>
Fri, 2 Feb 2018 16:21:43 +0000 (17:21 +0100)
Currently MediaWiki just dies silently, if the php
curl extension is missing.

Throw an exception instead that redirects the admin to the appropriate help page.

Change-Id: I25edfcb34ee5451a742cac6ae099019a16f6c417

includes/libs/MultiHttpClient.php

index 16168e6..3282ae2 100644 (file)
@@ -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 );