jenkins-bot has submitted this change and it was merged.

Change subject: Trigger onResponses on non-replacement request too in 
VirtualRESTServiceClient
......................................................................


Trigger onResponses on non-replacement request too in VirtualRESTServiceClient

Change-Id: I1e550812f3c021c2e2f4246345df2f9dd47d15b8
---
M includes/libs/virtualrest/VirtualRESTServiceClient.php
1 file changed, 9 insertions(+), 5 deletions(-)

Approvals:
  Ori.livneh: Looks good to me, approved
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/libs/virtualrest/VirtualRESTServiceClient.php 
b/includes/libs/virtualrest/VirtualRESTServiceClient.php
index 46be144..e8bb38d 100644
--- a/includes/libs/virtualrest/VirtualRESTServiceClient.php
+++ b/includes/libs/virtualrest/VirtualRESTServiceClient.php
@@ -208,6 +208,9 @@
                        if ( ++$rounds > 5 ) { // sanity
                                throw new Exception( "Too many replacement 
rounds detected. Aborting." );
                        }
+                       // Track requests executed this round that have a 
prefix/service.
+                       // Note that this also includes requests where 
'response' was forced.
+                       $checkReqIndexesByPrefix = array();
                        // Resolve the virtual URLs valid and qualified HTTP(S) 
URLs
                        // and add any required authentication headers for the 
backend.
                        // Services can also replace requests with new ones, 
either to
@@ -220,7 +223,7 @@
                                        if ( isset( $servReqs[$index] ) || 
isset( $origPending[$index] ) ) {
                                                // A current or original 
request which was not modified
                                        } else {
-                                               // Replacement requests with 
pre-set responses should not execute
+                                               // Replacement request that 
will convert to original requests
                                                
$newReplaceReqsByService[$prefix][$index] = $req;
                                        }
                                        if ( isset( $req['response'] ) ) {
@@ -232,6 +235,7 @@
                                                // Original or mangled request 
included
                                                $executeReqs[$index] = $req;
                                        }
+                                       
$checkReqIndexesByPrefix[$prefix][$index] = 1;
                                }
                        }
                        // Update index of requests to inspect for replacement
@@ -246,12 +250,12 @@
                        // defer the original or to set a proxy response to the 
original.
                        // Any replacement requests executed above will need to 
be replaced
                        // with new requests (eventually the original). The 
responses can be
-                       // forced instead of having the request sent over the 
wire.
+                       // forced by setting 'response' rather than actually be 
sent over the wire.
                        $newReplaceReqsByService = array();
-                       foreach ( $replaceReqsByService as $prefix => $servReqs 
) {
+                       foreach ( $checkReqIndexesByPrefix as $prefix => 
$servReqIndexes ) {
                                $service = $this->instances[$prefix];
-                               // Only the request copies stored in $doneReqs 
actually have the response
-                               $servReqs = array_intersect_key( $doneReqs, 
$servReqs );
+                               // $doneReqs actually has the requests (with 
'response' set)
+                               $servReqs = array_intersect_key( $doneReqs, 
$servReqIndexes );
                                foreach ( $service->onResponses( $servReqs, 
$idFunc ) as $index => $req ) {
                                        // Services use unique IDs for 
replacement requests
                                        if ( isset( $servReqs[$index] ) || 
isset( $origPending[$index] ) ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1e550812f3c021c2e2f4246345df2f9dd47d15b8
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to