Mholloway has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404095 )

Change subject: Only return info for enabled carriers from API type=carriers
......................................................................

Only return info for enabled carriers from API type=carriers

Varnish obtains the set of carriers and IP ranges for which to perform
header enrichment from the zeroportal API module via the periodically-
run zerofetch.py script.[1] This API module currently returns information
on both enabled and disabled carriers, and varnish adds Zero-related
headers for requests from configured IP ranges for enabled and disabled
carriers alike.

This is currently causing trouble because we are blocking users with Zero
IPs from accessing uploaded files in Phabricator (e.g., all images). This
block is currently mistakenly affecting users on previously active but
currently disabled carriers.

This updates the API module to return info only for currently enabled
carriers for the relevant request.

[1] 
https://phabricator.wikimedia.org/source/operations-puppet/browse/production/modules/varnish/files/zerofetch.py

Bug: T173537
Change-Id: I26d14fcb807168cd5062f394d8d42ae2b2c9b116
---
M includes/ApiZeroPortal.php
1 file changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroPortal 
refs/changes/95/404095/1

diff --git a/includes/ApiZeroPortal.php b/includes/ApiZeroPortal.php
index 674d451..f75ba95 100644
--- a/includes/ApiZeroPortal.php
+++ b/includes/ApiZeroPortal.php
@@ -72,12 +72,14 @@
                        case 'carriers':
                                $processor = function ( ZeroConfig $content, 
$title ) use ( $result, $moduleName ) {
                                        foreach ( $content->getIpsets() as 
$name => $ipset ) {
-                                               $result->addValue(
-                                                       $moduleName,
-                                                       $name === 'default' ? 
$title : $title . '|' . $name,
-                                                       $ipset,
-                                                       ApiResult::NO_SIZE_CHECK
-                                               );
+                                               if ( $content->enabled() ) {
+                                                       $result->addValue(
+                                                               $moduleName,
+                                                               $name === 
'default' ? $title : $title . '|' . $name,
+                                                               $ipset,
+                                                               
ApiResult::NO_SIZE_CHECK
+                                                       );
+                                               }
                                        }
                                };
                                break;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26d14fcb807168cd5062f394d8d42ae2b2c9b116
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroPortal
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>

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

Reply via email to