jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/344816 )

Change subject: Forward request details to upstream API
......................................................................


Forward request details to upstream API

Bug: T161029
Change-Id: I71d9243a159317d186b97410f4bb07c090a2a1da
Depends-On: I16a2eec46ae9e0e242fe740be20e39a2422dc867
---
M includes/ServiceWiring.php
M includes/WikimediaPageViewService.php
2 files changed, 21 insertions(+), 1 deletion(-)

Approvals:
  jenkins-bot: Verified
  Anomie: Looks good to me, approved



diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php
index 6beabdd..cfa2284 100644
--- a/includes/ServiceWiring.php
+++ b/includes/ServiceWiring.php
@@ -5,6 +5,7 @@
 use MediaWiki\Logger\LoggerFactory;
 use MediaWiki\MediaWikiServices;
 use ObjectCache;
+use RequestContext;
 
 return [
        'PageViewService' => function ( MediaWikiServices $services ) {
@@ -20,6 +21,7 @@
                $service = new WikimediaPageViewService( $endpoint, [ 'project' 
=> $project ],
                        $extensionConfig->get( 
'PageViewInfoWikimediaRequestLimit' ) );
                $service->setLogger( $logger );
+               $service->setOriginalRequest( 
RequestContext::getMain()->getRequest() );
                $cachedService = new CachedPageViewService( $service, $cache );
                $cachedService->setCachedDays( $cachedDays );
                $cachedService->setLogger( $logger );
diff --git a/includes/WikimediaPageViewService.php 
b/includes/WikimediaPageViewService.php
index 60e7cb3..e0e832e 100644
--- a/includes/WikimediaPageViewService.php
+++ b/includes/WikimediaPageViewService.php
@@ -12,6 +12,7 @@
 use Status;
 use StatusValue;
 use Title;
+use WebRequest;
 
 /**
  * PageViewService implementation for Wikimedia wikis, using the pageview API
@@ -41,6 +42,11 @@
 
        /** @var array Cache for getEmptyDateRange() */
        protected $range;
+
+       /** @var WebRequest|string[] The request that asked for this data; see 
the originalRequest
+        *    parameter of Http::request()
+        */
+       protected $originalRequest;
 
        /**
         * @param string $endpoint Wikimedia pageview API endpoint
@@ -73,6 +79,14 @@
 
        public function setLogger( LoggerInterface $logger ) {
                $this->logger = $logger;
+       }
+
+       /**
+        * @param $originalRequest WebRequest|string[] See the 
'originalRequest' parameter of
+        *   Http::request().
+        */
+       public function setOriginalRequest( $originalRequest ) {
+               $this->originalRequest = $originalRequest;
        }
 
        public function supports( $metric, $scope ) {
@@ -306,7 +320,11 @@
         * @return MWHttpRequest
         */
        protected function requestFactory( $url, $caller ) {
-               return MWHttpRequest::factory( $url, [ 'timeout' => 10 ], 
$caller );
+               $request = MWHttpRequest::factory( $url, [ 'timeout' => 10 ], 
$caller );
+               if ( $this->originalRequest ) {
+                       $request->setOriginalRequest( $this->originalRequest );
+               }
+               return $request;
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I71d9243a159317d186b97410f4bb07c090a2a1da
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/PageViewInfo
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to