Instead of silently discarding errors in server-side HTTP requests,
log them to a 'http' channel.
Make ForeignAPIFile::httpGet() (which sort of reimplements Http::get())
log to the same channel, for consistency.
Bug: T103043
Change-Id: Ibf552e22adc7fde4a751f92e92dad6ceba2f335c
* @defgroup HTTP HTTP
*/
+use MediaWiki\Logger\LoggerFactory;
+
/**
* Various HTTP related functions
* @ingroup 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;
}
/**
* @ingroup FileRepo
*/
+use MediaWiki\Logger\LoggerFactory;
+
/**
* A foreign repository with a remote MediaWiki with an API thingy
*
if ( $status->isOK() ) {
return $req->getContent();
} else {
- wfDebug( "ForeignAPIRepo: ERROR on GET: " . $status->getWikiText() );
+ $logger = LoggerFactory::getInstance( 'http' );
+ $logger->warning( $status->getWikiText(), array( 'caller' => 'ForeignAPIRepo::httpGet' ) );
return false;
}
}