Log errors in Http::request()
[lhc/web/wiklou.git] / includes / HttpFunctions.php
index 7b43a2d..fec8adc 100644 (file)
@@ -25,6 +25,8 @@
  * @defgroup HTTP HTTP
  */
 
+use MediaWiki\Logger\LoggerFactory;
+
 /**
  * Various HTTP related functions
  * @ingroup HTTP
@@ -73,11 +75,14 @@ class Http {
                $req = MWHttpRequest::factory( $url, $options, $caller );
                $status = $req->execute();
 
-               $content = false;
                if ( $status->isOK() ) {
-                       $content = $req->getContent();
+                       return $req->getContent();
+               } else {
+                       $errors = $status->getErrorsByType( 'error' );
+                       $logger = LoggerFactory::getInstance( 'http' );
+                       $logger->warning( $status->getWikiText(), array( 'caller' => $caller ) );
+                       return false;
                }
-               return $content;
        }
 
        /**