Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/303980

Change subject: Use MWHttpRequest for easier debugging of errors
......................................................................

Use MWHttpRequest for easier debugging of errors

So we can send errors to a specific log channel.

Change-Id: I7cd254ca023dd7845a7e32d6d3800f9c2e941fc8
---
M includes/PageViewInfo.hooks.php
1 file changed, 11 insertions(+), 9 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaPageViewInfo 
refs/changes/80/303980/1

diff --git a/includes/PageViewInfo.hooks.php b/includes/PageViewInfo.hooks.php
index 04072dd..3847d24 100644
--- a/includes/PageViewInfo.hooks.php
+++ b/includes/PageViewInfo.hooks.php
@@ -5,7 +5,8 @@
 use IContextSource;
 use FormatJson;
 use Html;
-use Http;
+use MWHttpRequest;
+use MediaWiki\Logger\LoggerFactory;
 use Title;
 
 class Hooks {
@@ -82,17 +83,18 @@
                $today = date( 'Ymd' );
                $lastMonth = date( 'Ymd', time() - ( 60 * 60 * 24 * 30 ) );
                $url = self::buildApiUrl( $title, $lastMonth, $today );
-               $req = Http::get(
-                       $url,
-                       [ 'timeout' => 10 ],
-                       __METHOD__
-               );
-
-               if ( $req === false ) {
+               $req = MWHttpRequest::factory( $url, [ 'timeout' => 10 ], 
__METHOD__ );
+               $status = $req->execute();
+               if ( !$status->isOK() ) {
+                       LoggerFactory::getInstance( 'PageViewInfo' )
+                               ->error( "Failed fetching $url: 
{$status->getWikiText()}", [
+                                       'url' => $url,
+                                       'title' => $title->getPrefixedText()
+                               ] );
                        return false;
                }
 
-               $data = FormatJson::decode( $req, true );
+               $data = FormatJson::decode( $req->getContent(), true );
                // Add our start/end periods
                $data['start'] = $lastMonth;
                $data['end'] = $today;

-- 
To view, visit https://gerrit.wikimedia.org/r/303980
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7cd254ca023dd7845a7e32d6d3800f9c2e941fc8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaPageViewInfo
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to