Merge "Add error checking for file argument"
[lhc/web/wiklou.git] / includes / HttpFunctions.php
index 578b535..e6801e3 100644 (file)
@@ -80,7 +80,8 @@ class Http {
                } else {
                        $errors = $status->getErrorsByType( 'error' );
                        $logger = LoggerFactory::getInstance( 'http' );
-                       $logger->warning( $status->getWikiText(), array( 'caller' => $caller ) );
+                       $logger->warning( $status->getWikiText(),
+                               array( 'error' => $errors, 'caller' => $caller, 'content' => $req->getContent() ) );
                        return false;
                }
        }
@@ -250,7 +251,9 @@ class MWHttpRequest {
         * @param string $caller The method making this request, for profiling
         * @param Profiler $profiler An instance of the profiler for profiling, or null
         */
-       protected function __construct( $url, $options = array(), $caller = __METHOD__, $profiler = null ) {
+       protected function __construct(
+               $url, $options = array(), $caller = __METHOD__, $profiler = null
+       ) {
                global $wgHTTPTimeout, $wgHTTPConnectTimeout;
 
                $this->url = wfExpandUrl( $url, PROTO_HTTP );
@@ -870,8 +873,10 @@ class PhpHttpRequest extends MWHttpRequest {
        }
 
        /**
-        * Returns an array with a 'capath' or 'cafile' key that is suitable to be merged into the 'ssl' sub-array of a
-        * stream context options array. Uses the 'caInfo' option of the class if it is provided, otherwise uses the system
+        * Returns an array with a 'capath' or 'cafile' key
+        * that is suitable to be merged into the 'ssl' sub-array of
+        * a stream context options array.
+        * Uses the 'caInfo' option of the class if it is provided, otherwise uses the system
         * default CA bundle if PHP supports that, or searches a few standard locations.
         * @return array
         * @throws DomainException
@@ -882,10 +887,13 @@ class PhpHttpRequest extends MWHttpRequest {
                if ( $this->caInfo ) {
                        $certLocations = array( 'manual' => $this->caInfo );
                } elseif ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
+                       // @codingStandardsIgnoreStart Generic.Files.LineLength
                        // Default locations, based on
                        // https://www.happyassassin.net/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/
-                       // PHP 5.5 and older doesn't have any defaults, so we try to guess ourselves. PHP 5.6+ gets the CA location
-                       // from OpenSSL as long as it is not set manually, so we should leave capath/cafile empty there.
+                       // PHP 5.5 and older doesn't have any defaults, so we try to guess ourselves.
+                       // PHP 5.6+ gets the CA location from OpenSSL as long as it is not set manually,
+                       // so we should leave capath/cafile empty there.
+                       // @codingStandardsIgnoreEnd
                        $certLocations = array_filter( array(
                                getenv( 'SSL_CERT_DIR' ),
                                getenv( 'SSL_CERT_PATH' ),
@@ -914,8 +922,10 @@ class PhpHttpRequest extends MWHttpRequest {
        }
 
        /**
-        * Custom error handler for dealing with fopen() errors. fopen() tends to fire multiple errors in succession, and the last one
-        * is completely useless (something like "fopen: failed to open stream") so normal methods of handling errors programmatically
+        * Custom error handler for dealing with fopen() errors.
+        * fopen() tends to fire multiple errors in succession, and the last one
+        * is completely useless (something like "fopen: failed to open stream")
+        * so normal methods of handling errors programmatically
         * like get_last_error() don't work.
         */
        public function errorHandler( $errno, $errstr ) {
@@ -962,6 +972,8 @@ class PhpHttpRequest extends MWHttpRequest {
                        'ssl' => array(
                                'verify_peer' => $this->sslVerifyCert,
                                'SNI_enabled' => true,
+                               'ciphers' => 'HIGH:!SSLv2:!SSLv3:-ADH:-kDH:-kECDH:-DSS',
+                               'disable_compression' => true,
                        ),
                );