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

Change subject: [WIP] Rename CDN config variables to be generic, deprecating 
the old names
......................................................................

[WIP] Rename CDN config variables to be generic, deprecating the old names

Untested. Messy. Not totally sure this is a good idea.

Should https://www.mediawiki.org/wiki/Manual:Squid_caching be renamed too?

Bug: T104148
Change-Id: I7a725dae551c867a4fa7c213838d52c7fb862756
---
M includes/AjaxResponse.php
M includes/Block.php
M includes/DefaultSettings.php
M includes/MediaWiki.php
M includes/OutputPage.php
M includes/ServiceWiring.php
M includes/Setup.php
M includes/actions/RawAction.php
M includes/api/ApiMain.php
M includes/clientpool/SquidPurgeClient.php
M includes/deferred/CdnCacheUpdate.php
M includes/skins/Skin.php
M maintenance/benchmarks/benchmarkPurge.php
M tests/phpunit/includes/WebRequestTest.php
M thumb.php
15 files changed, 157 insertions(+), 67 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/77/387877/1

diff --git a/includes/AjaxResponse.php b/includes/AjaxResponse.php
index 3e42c08..2c18cab 100644
--- a/includes/AjaxResponse.php
+++ b/includes/AjaxResponse.php
@@ -180,12 +180,19 @@
                        # and tell the client to always check with the CDN. 
Otherwise,
                        # tell the client to use a cached copy, without a way 
to purge it.
 
-                       if ( $this->mConfig->get( 'UseSquid' ) ) {
+                       $config = $this->mConfig;
+
+                       // Backwards-compatibility reading of old $wgUseSquid 
setting as of MediaWiki 1.31
+                       $configUseCdn = $config->has( 'UseSquid' ) ?
+                               $config->get( 'UseSquid' ) :
+                               $config->get( 'UseCdn' );
+
+                       if ( $configUseCdn ) {
                                # Expect explicit purge of the proxy cache, but 
require end user agents
                                # to revalidate against the proxy on each visit.
                                # Surrogate-Control controls our CDN, 
Cache-Control downstream caches
 
-                               if ( $this->mConfig->get( 'UseESI' ) ) {
+                               if ( $config->get( 'UseESI' ) ) {
                                        header( 'Surrogate-Control: max-age=' . 
$this->mCacheDuration . ', content="ESI/1.0"' );
                                        header( 'Cache-Control: s-maxage=0, 
must-revalidate, max-age=0' );
                                } else {
diff --git a/includes/Block.php b/includes/Block.php
index d1e78bb..16ce1a6 100644
--- a/includes/Block.php
+++ b/includes/Block.php
@@ -1203,7 +1203,7 @@
                        if ( !IP::isValid( $ipaddr ) ) {
                                continue;
                        }
-                       # Don't check trusted IPs (includes local squids which 
will be in every request)
+                       # Don't check trusted IPs (includes local CDNs which 
will be in every request)
                        if ( $proxyLookup->isTrustedProxy( $ipaddr ) ) {
                                continue;
                        }
@@ -1264,7 +1264,7 @@
         * @param array $ipChain List of IPs (strings). This is used to 
determine how "close"
         *     a block is to the server, and if a block matches exactly, or is 
in a range.
         *     The order is furthest from the server to nearest e.g., (Browser, 
proxy1, proxy2,
-        *     local-squid, ...)
+        *     local-cdn, ...)
         * @throws MWException
         * @return Block|null The "best" block from the list
         */
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index d9f032c..608edb1 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -2650,7 +2650,8 @@
  * @name   HTTP proxy (CDN) settings
  *
  * Many of these settings apply to any HTTP proxy used in front of MediaWiki,
- * although they are referred to as Squid settings for historical reasons.
+ * although they are sometimes still referred to as Squid settings for
+ * historical reasons.
  *
  * Achieving a high hit ratio with an HTTP proxy requires special
  * configuration. See https://www.mediawiki.org/wiki/Manual:Squid_caching for
@@ -2662,8 +2663,10 @@
 /**
  * Enable/disable CDN.
  * See https://www.mediawiki.org/wiki/Manual:Squid_caching
+ *
+ * @since 1.31 Renamed from $wgUseSquid.
  */
-$wgUseSquid = false;
+$wgUseCdn = false;
 
 /**
  * If you run Squid3 with ESI support, enable this (default:false):
@@ -2673,6 +2676,7 @@
 /**
  * Send the Key HTTP header for better caching.
  * See https://datatracker.ietf.org/doc/draft-fielding-http-key/ for details.
+ *
  * @since 1.27
  */
 $wgUseKeyHeader = false;
@@ -2703,12 +2707,15 @@
  * out s-maxage in the CDN config.
  *
  * 18000 seconds = 5 hours, more cache hits with 2678400 = 31 days.
+ *
+ * @since 1.31 Renamed from $wgSquidMaxage
  */
-$wgSquidMaxage = 18000;
+$wgCdnMaxAge = 18000;
 
 /**
  * Cache timeout for the CDN when DB replica DB lag is high
- * @see $wgSquidMaxage
+ * @see $wgCdnMaxAge
+ *
  * @since 1.27
  */
 $wgCdnMaxageLagged = 30;
@@ -2731,7 +2738,7 @@
 
 /**
  * Cache timeout for the CDN when a response is known to be wrong or 
incomplete (due to load)
- * @see $wgSquidMaxage
+ * @see $wgCdnMaxAge
  * @since 1.27
  */
 $wgCdnMaxageSubstitute = 60;
@@ -2750,20 +2757,24 @@
  * headers sent/modified from these proxies when obtaining the remote IP 
address
  *
  * For a list of trusted servers which *aren't* purged, see 
$wgSquidServersNoPurge.
+ *
+ * @since 1.31 Renamed from $wgSquidServers.
  */
-$wgSquidServers = [];
+$wgCdnServers = [];
 
 /**
- * As above, except these servers aren't purged on page changes; use to set a
- * list of trusted proxies, etc. Supports both individual IP addresses and
- * CIDR blocks.
+ * As with $wgCdnServers, except these servers aren't purged on page changes;
+ * use to set a list of trusted proxies, etc. Supports both individual IP
+ * addresses and CIDR blocks.
+ *
  * @since 1.23 Supports CIDR ranges
+ * @since 1.31 Renamed from $wgSquidServersNoPurge
  */
-$wgSquidServersNoPurge = [];
+$wgCdnServersNoPurge = [];
 
 /**
  * Whether to use a Host header in purge requests sent to the proxy servers
- * configured in $wgSquidServers. Set this to false to support Squid
+ * configured in $wgCdnServers. Set this to false to support a CDN
  * configured in forward-proxy mode.
  *
  * If this is set to true, a Host header will be sent, and only the path
@@ -2779,8 +2790,9 @@
  * reverse).
  *
  * @since 1.21
+ * @since 1.31 Renamed from $wgSquidPurgeUseHostHeader
  */
-$wgSquidPurgeUseHostHeader = true;
+$wgCdnPurgeUseHostHeader = true;
 
 /**
  * Routing configuration for HTCP multicast purging. Add elements here to
@@ -6399,7 +6411,7 @@
 /**
  * Display the new debugging toolbar. This also enables profiling on database
  * queries and other useful output.
- * Will be ignored if $wgUseFileCache or $wgUseSquid is enabled.
+ * Will be ignored if $wgUseFileCache or $wgUseCdn is enabled.
  *
  * @since 1.19
  */
diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php
index 43de4ba..dec89b2 100644
--- a/includes/MediaWiki.php
+++ b/includes/MediaWiki.php
@@ -367,7 +367,7 @@
                        }
                        throw new HttpError( 500, $message );
                }
-               $output->setSquidMaxage( 1200 );
+               $output->setCdnMaxage( 1200 );
                $output->redirect( $targetUrl, '301' );
                return true;
        }
@@ -485,15 +485,24 @@
                                $request->markAsSafeRequest();
                        }
 
+                       // Backwards-compatibility reading of old $wgUseSquid 
setting as of MediaWiki 1.31
+                       $configUseCdn = $this->$config->has( 'UseSquid' ) ?
+                               $this->$config->get( 'UseSquid' ) :
+                               $this->$config->get( 'UseCdn' );
+                       // Backwards-compatibility reading of old 
$wgSquidMaxage setting as of MediaWiki 1.31
+                       $configCdnMaxAge = $this->$config->has( 'SquidMaxage' ) 
?
+                               $this->$config->get( 'SquidMaxage' ) :
+                               $this->$config->get( 'CdnMaxAge' );
+
                        # Let CDN cache things if we can purge them.
-                       if ( $this->config->get( 'UseSquid' ) &&
+                       if ( $configUseCdn &&
                                in_array(
                                        // Use PROTO_INTERNAL because that's 
what getCdnUrls() uses
                                        wfExpandUrl( $request->getRequestURL(), 
PROTO_INTERNAL ),
                                        $requestTitle->getCdnUrls()
                                )
                        ) {
-                               $output->setCdnMaxage( $this->config->get( 
'SquidMaxage' ) );
+                               $output->setCdnMaxage( $configCdnMaxAge );
                        }
 
                        $action->show();
diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 500be8d..7dd5dba 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -794,9 +794,19 @@
                        'user' => $this->getUser()->getTouched(),
                        'epoch' => $config->get( 'CacheEpoch' )
                ];
-               if ( $config->get( 'UseSquid' ) ) {
+
+               // Backwards-compatibility reading of old $wgUseSquid setting 
as of MediaWiki 1.31
+               $configUseCdn = $config->has( 'UseSquid' ) ?
+                       $config->get( 'UseSquid' ) :
+                       $config->get( 'UseCdn' );
+               // Backwards-compatibility reading of old $wgSquidMaxage 
setting as of MediaWiki 1.31
+               $configCdnMaxAge = $config->has( 'SquidMaxage' ) ?
+                       $config->get( 'SquidMaxage' ) :
+                       $config->get( 'CdnMaxAge' );
+
+               if ( $configUseCdn ) {
                        // T46570: the core page itself may not change, but 
resources might
-                       $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - 
$config->get( 'SquidMaxage' ) );
+                       $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - 
$configCdnMaxAge );
                }
                Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, 
$this ] );
 
@@ -2008,13 +2018,18 @@
         *
         * @param string|int|float|bool|null $mtime Last-Modified timestamp
         * @param int $minTTL Mimimum TTL in seconds [default: 1 minute]
-        * @param int $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage]
+        * @param int $maxTTL Maximum TTL in seconds [default: $wgCdnMaxAge]
         * @return int TTL in seconds
         * @since 1.28
         */
        public function adaptCdnTTL( $mtime, $minTTL = 0, $maxTTL = 0 ) {
+               // Backwards-compatibility reading of old $wgSquidMaxage 
setting as of MediaWiki 1.31
+               $configCdnMaxAge = $this->getConfig()->has( 'SquidMaxage' ) ?
+                       $this->getConfig()->get( 'SquidMaxage' ) :
+                       $this->getConfig()->get( 'CdnMaxAge' );
+
                $minTTL = $minTTL ?: IExpiringStore::TTL_MINUTE;
-               $maxTTL = $maxTTL ?: $this->getConfig()->get( 'SquidMaxage' );
+               $maxTTL = $maxTTL ?: $configCdnMaxAge;
 
                if ( $mtime === null || $mtime === false ) {
                        return $minTTL; // entity does not exist
@@ -2273,9 +2288,18 @@
                        $response->header( $this->getKeyHeader() );
                }
 
+               // Backwards-compatibility reading of old $wgUseSquid setting 
as of MediaWiki 1.31
+               $configUseCdn = $config->has( 'UseSquid' ) ?
+                       $config->get( 'UseSquid' ) :
+                       $config->get( 'UseCdn' );
+               // Backwards-compatibility reading of old $wgSquidMaxage 
setting as of MediaWiki 1.31
+               $configCdnMaxAge = $config->has( 'SquidMaxage' ) ?
+                       $config->get( 'SquidMaxage' ) :
+                       $config->get( 'CdnMaxAge' );
+
                if ( $this->mEnableClientCache ) {
                        if (
-                               $config->get( 'UseSquid' ) &&
+                               $configUseCdn &&
                                !$response->hasCookies() &&
                                
!SessionManager::getGlobalSession()->isPersistent() &&
                                !$this->isPrintable() &&
@@ -2291,7 +2315,7 @@
                                        # start with a shorter timeout for 
initial testing
                                        # header( 'Surrogate-Control: 
max-age=2678400+2678400, content="ESI/1.0"');
                                        $response->header(
-                                               "Surrogate-Control: 
max-age={$config->get( 'SquidMaxage' )}" .
+                                               "Surrogate-Control: 
max-age={$configCdnMaxAge}" .
                                                "+{$this->mCdnMaxage}, 
content=\"ESI/1.0\""
                                        );
                                        $response->header( 'Cache-Control: 
s-maxage=0, must-revalidate, max-age=0' );
diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php
index 0496b67..84faf77 100644
--- a/includes/ServiceWiring.php
+++ b/includes/ServiceWiring.php
@@ -277,10 +277,17 @@
 
        'ProxyLookup' => function ( MediaWikiServices $services ) {
                $mainConfig = $services->getMainConfig();
-               return new ProxyLookup(
-                       $mainConfig->get( 'SquidServers' ),
-                       $mainConfig->get( 'SquidServersNoPurge' )
-               );
+
+               // Backwards-compatibility reading of old $wgSquidServers 
setting as of MediaWiki 1.31
+               $configCdnServers = $config->has( 'SquidServers' ) ?
+                       $mainConfig->get( 'SquidServers' ) :
+                       $mainConfig->get( 'CdnServers' );
+               // Backwards-compatibility reading of old 
$wgSquidServersNoPurge setting as of MediaWiki 1.31
+               $configCdnServersNoPurge = $config->has( 'SquidServersNoPurge' 
) ?
+                       $mainConfig->get( 'SquidServersNoPurge' ) :
+                       $mainConfig->get( 'CdnServersNoPurge' );
+
+               return new ProxyLookup( $configCdnServers, 
$configCdnServersNoPurge );
        },
 
        'Parser' => function ( MediaWikiServices $services ) {
diff --git a/includes/Setup.php b/includes/Setup.php
index e4396ba..ebc15dc 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -517,7 +517,8 @@
 
 // Easy to forget to falsify $wgDebugToolbar for static caches.
 // If file cache or CDN cache is on, just disable this (DWIMD).
-if ( $wgUseFileCache || $wgUseSquid ) {
+// Backwards-compatibility reading of old $wgUseSquid setting as of MediaWiki 
1.31
+if ( $wgUseFileCache || ( isset( $wgUseSquid ) ? $wgUseSquid : $wgUseCdn ) ) {
        $wgDebugToolbar = false;
 }
 
diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php
index be10ae4..acc7caa 100644
--- a/includes/actions/RawAction.php
+++ b/includes/actions/RawAction.php
@@ -66,7 +66,12 @@
 
                $contentType = $this->getContentType();
 
-               $maxage = $request->getInt( 'maxage', $config->get( 
'SquidMaxage' ) );
+               // Backwards-compatibility reading of old $wgSquidMaxage 
setting as of MediaWiki 1.31
+               $configMaxAge = $config->has( 'SquidMaxage' ) ?
+                       $config->get( 'SquidMaxage' ) :
+                       $config->get( 'CdnMaxAge' );
+
+               $maxage = $request->getInt( 'maxage', $configMaxAge );
                $smaxage = $request->getIntOrNull( 'smaxage' );
                if ( $smaxage === null ) {
                        if ( $contentType == 'text/css' || $contentType == 
'text/javascript' ) {
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index edc1a3e..1aa10a3 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1370,18 +1370,30 @@
                                                $ts->format( 'D M j H:i:s Y' ) 
=== $value ||
                                                $ts->format( 'D M  j H:i:s Y' ) 
=== $value
                                        ) {
+                                               $config = $this->getConfig();
                                                $lastMod = 
$module->getConditionalRequestData( 'last-modified' );
                                                if ( $lastMod !== null ) {
                                                        // Mix in some 
MediaWiki modification times
                                                        $modifiedTimes = [
                                                                'page' => 
$lastMod,
                                                                'user' => 
$this->getUser()->getTouched(),
-                                                               'epoch' => 
$this->getConfig()->get( 'CacheEpoch' ),
+                                                               'epoch' => 
$config->get( 'CacheEpoch' ),
                                                        ];
-                                                       if ( 
$this->getConfig()->get( 'UseSquid' ) ) {
+
+                                                       // 
Backwards-compatibility reading of old $wgUseSquid setting as of MediaWiki 1.31
+                                                       $configUseCdn = 
$config->has( 'UseSquid' ) ?
+                                                               $config->get( 
'UseSquid' ) :
+                                                               $config->get( 
'UseCdn' );
+
+                                                       // 
Backwards-compatibility reading of old $wgSquidMaxage setting as of MediaWiki 
1.31
+                                                       $configCdnMaxAge = 
$config->has( 'SquidMaxage' ) ?
+                                                               $config->get( 
'SquidMaxage' ) :
+                                                               $config->get( 
'CdnMaxAge' );
+
+                                                       if ( $configUseCdn ) {
                                                                // T46570: the 
core page itself may not change, but resources might
                                                                
$modifiedTimes['sepoch'] = wfTimestamp(
-                                                                       TS_MW, 
time() - $this->getConfig()->get( 'SquidMaxage' )
+                                                                       TS_MW, 
time() - $configCdnMaxAge
                                                                );
                                                        }
                                                        Hooks::run( 
'OutputPageCheckLastModified', [ &$modifiedTimes, $this->getOutput() ] );
diff --git a/includes/clientpool/SquidPurgeClient.php 
b/includes/clientpool/SquidPurgeClient.php
index f454bd4..264b928 100644
--- a/includes/clientpool/SquidPurgeClient.php
+++ b/includes/clientpool/SquidPurgeClient.php
@@ -151,7 +151,7 @@
                        if ( IP::isIPv4( $this->host ) ) {
                                $this->ip = $this->host;
                        } elseif ( IP::isIPv6( $this->host ) ) {
-                               throw new MWException( '$wgSquidServers does 
not support IPv6' );
+                               throw new MWException( '$wgCdnServers does not 
support IPv6' );
                        } else {
                                MediaWiki\suppressWarnings();
                                $this->ip = gethostbyname( $this->host );
@@ -195,10 +195,11 @@
         * @param string $url
         */
        public function queuePurge( $url ) {
-               global $wgSquidPurgeUseHostHeader;
+               global $wgSquidPurgeUseHostHeader, $wgCdnPurgeUseHostHeader;
                $url = CdnCacheUpdate::expand( str_replace( "\n", '', $url ) );
                $request = [];
-               if ( $wgSquidPurgeUseHostHeader ) {
+               // Backwards-compatibility reading of old 
$wgSquidPurgeUseHostHeader setting as of MediaWiki 1.31
+               if ( isset( $wgSquidPurgeUseHostHeader ) ? 
$wgSquidPurgeUseHostHeader : $wgCdnPurgeUseHostHeader ) {
                        $url = wfParseUrl( $url );
                        $host = $url['host'];
                        if ( isset( $url['port'] ) && strlen( $url['port'] ) > 
0 ) {
diff --git a/includes/deferred/CdnCacheUpdate.php 
b/includes/deferred/CdnCacheUpdate.php
index 7fafc0e..db019d7 100644
--- a/includes/deferred/CdnCacheUpdate.php
+++ b/includes/deferred/CdnCacheUpdate.php
@@ -92,14 +92,14 @@
        }
 
        /**
-        * Purges a list of CDN nodes defined in $wgSquidServers.
+        * Purges a list of CDN nodes defined in $wgCdnServers.
         * $urlArr should contain the full URLs to purge as values
         * (example: $urlArr[] = 'http://my.host/something')
         *
         * @param string[] $urlArr List of full URLs to purge
         */
        public static function purge( array $urlArr ) {
-               global $wgSquidServers, $wgHTCPRouting;
+               global $wgCdnServers, $wgSquidServers, $wgHTCPRouting;
 
                if ( !$urlArr ) {
                        return;
@@ -132,21 +132,24 @@
                        self::HTCPPurge( $urlArr );
                }
 
+               // Backwards-compatibility reading of old $wgSquidServers 
setting as of MediaWiki 1.31
+               $configCdnServers = isset( $wgSquidServers ) ? $wgSquidServers 
: $wgCdnServers;
+
                // Do direct server purges if enabled (this does not scale very 
well)
-               if ( $wgSquidServers ) {
-                       // Maximum number of parallel connections per squid
-                       $maxSocketsPerSquid = 8;
+               if ( $configCdnServers ) {
+                       // Maximum number of parallel connections per CDN
+                       $maxSocketsPerCdn = 8;
                        // Number of requests to send per socket
                        // 400 seems to be a good tradeoff, opening a socket 
takes a while
                        $urlsPerSocket = 400;
-                       $socketsPerSquid = ceil( count( $urlArr ) / 
$urlsPerSocket );
-                       if ( $socketsPerSquid > $maxSocketsPerSquid ) {
-                               $socketsPerSquid = $maxSocketsPerSquid;
+                       $socketsPerCdn = ceil( count( $urlArr ) / 
$urlsPerSocket );
+                       if ( $socketsPerCdn > $maxSocketsPerCdn ) {
+                               $socketsPerCdn = $maxSocketsPerCdn;
                        }
 
                        $pool = new SquidPurgeClientPool;
-                       $chunks = array_chunk( $urlArr, ceil( count( $urlArr ) 
/ $socketsPerSquid ) );
-                       foreach ( $wgSquidServers as $server ) {
+                       $chunks = array_chunk( $urlArr, ceil( count( $urlArr ) 
/ $socketsPerCdn ) );
+                       foreach ( $configCdnServers as $server ) {
                                foreach ( $chunks as $chunk ) {
                                        $client = new SquidPurgeClient( $server 
);
                                        foreach ( $chunk as $url ) {
diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php
index 07964a4..ad32e3e 100644
--- a/includes/skins/Skin.php
+++ b/includes/skins/Skin.php
@@ -395,14 +395,17 @@
         * @return array
         */
        public static function getDynamicStylesheetQuery() {
-               global $wgSquidMaxage;
+               global $wgSquidMaxage, $wgCdnMaxAge;
+
+               // Backwards-compatibility reading of old $wgSquidMaxage 
setting as of MediaWiki 1.31
+               $configCdnMaxAge = isset( $wgSquidMaxage ) ? $wgSquidMaxage : 
$wgCdnMaxAge;
 
                return [
                                'action' => 'raw',
-                               'maxage' => $wgSquidMaxage,
+                               'maxage' => $configCdnMaxAge,
                                'usemsgcache' => 'yes',
                                'ctype' => 'text/css',
-                               'smaxage' => $wgSquidMaxage,
+                               'smaxage' => $configCdnMaxAge,
                        ];
        }
 
diff --git a/maintenance/benchmarks/benchmarkPurge.php 
b/maintenance/benchmarks/benchmarkPurge.php
index e006cf5..ad9d26d 100644
--- a/maintenance/benchmarks/benchmarkPurge.php
+++ b/maintenance/benchmarks/benchmarkPurge.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * Benchmark for Squid purge.
+ * Benchmark for CDN purge.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,22 +24,28 @@
 require_once __DIR__ . '/Benchmarker.php';
 
 /**
- * Maintenance script that benchmarks Squid purge.
+ * Maintenance script that benchmarks CDN purge.
  *
  * @ingroup Benchmark
  */
 class BenchmarkPurge extends Benchmarker {
        public function __construct() {
                parent::__construct();
-               $this->addDescription( 'Benchmark the Squid purge functions.' );
+               $this->addDescription( 'Benchmark the CDN purge functions.' );
        }
 
        public function execute() {
-               global $wgUseSquid, $wgSquidServers;
-               if ( !$wgUseSquid ) {
-                       $this->error( "Squid purge benchmark doesn't do much 
without squid support on.", true );
+               global $wgUseSquid, $wgUseCdn, $wgSquidServers, $wgCdnServers;
+
+               // Backwards-compatibility reading of old $wgSquidMaxage 
setting as of MediaWiki 1.31
+               $configCdnMaxAge = isset( $wgSquidMaxage ) ? $wgSquidMaxage : 
$wgCdnMaxAge;
+               // Backwards-compatibility reading of old $wgSquidServers 
setting as of MediaWiki 1.31
+               $configCdnServers = isset( $wgSquidServers ) ? $wgSquidServers 
: $wgCdnServers;
+
+               if ( !$configUseCdn ) {
+                       $this->error( "CDN purge benchmark doesn't do much 
without CDN support on.", true );
                } else {
-                       $this->output( "There are " . count( $wgSquidServers ) 
. " defined squid servers:\n" );
+                       $this->output( "There are " . count( $configCdnServers 
) . " defined CDN servers:\n" );
                        if ( $this->hasOption( 'count' ) ) {
                                $lengths = [ intval( $this->getOption( 'count' 
) ) ];
                        } else {
@@ -47,20 +53,20 @@
                        }
                        foreach ( $lengths as $length ) {
                                $urls = $this->randomUrlList( $length );
-                               $trial = $this->benchSquid( $urls );
+                               $trial = $this->benchCdn( $urls );
                                $this->output( $trial . "\n" );
                        }
                }
        }
 
        /**
-        * Run a bunch of URLs through SquidUpdate::purge()
-        * to benchmark Squid response times.
+        * Run a bunch of URLs through CdnCacheUpdate::purge()
+        * to benchmark CDN response times.
         * @param array $urls A bunch of URLs to purge
         * @param int $trials How many times to run the test?
         * @return string
         */
-       private function benchSquid( $urls, $trials = 1 ) {
+       private function benchCdn( $urls, $trials = 1 ) {
                $start = microtime( true );
                for ( $i = 0; $i < $trials; $i++ ) {
                        CdnCacheUpdate::purge( $urls );
diff --git a/tests/phpunit/includes/WebRequestTest.php 
b/tests/phpunit/includes/WebRequestTest.php
index 041e7e3..37a8d9d 100644
--- a/tests/phpunit/includes/WebRequestTest.php
+++ b/tests/phpunit/includes/WebRequestTest.php
@@ -362,7 +362,7 @@
         * @dataProvider provideGetIP
         * @covers WebRequest::getIP
         */
-       public function testGetIP( $expected, $input, $squid, $xffList, 
$private, $description ) {
+       public function testGetIP( $expected, $input, $cdn, $xffList, $private, 
$description ) {
                $_SERVER = $input;
                $this->setMwGlobals( [
                        'wgUsePrivateIPs' => $private,
@@ -376,7 +376,7 @@
                        ]
                ] );
 
-               $this->setService( 'ProxyLookup', new ProxyLookup( [], $squid ) 
);
+               $this->setService( 'ProxyLookup', new ProxyLookup( [], $cdn ) );
 
                $request = new WebRequest();
                $result = $request->getIP();
@@ -558,8 +558,8 @@
        public function testGetIpLackOfRemoteAddrThrowAnException() {
                // ensure that local install state doesn't interfere with test
                $this->setMwGlobals( [
-                       'wgSquidServersNoPurge' => [],
-                       'wgSquidServers' => [],
+                       'wgCdnServers' => [],
+                       'wgCdnServersNoPurge' => [],
                        'wgUsePrivateIPs' => false,
                        'wgHooks' => [],
                ] );
diff --git a/thumb.php b/thumb.php
index 7c3e757..7a7f5a5 100644
--- a/thumb.php
+++ b/thumb.php
@@ -272,7 +272,7 @@
 
        // For 404 handled thumbnails, we only use the base name of the URI
        // for the thumb params and the parent directory for the source file 
name.
-       // Check that the zone relative path matches up so squid caches won't 
pick
+       // Check that the zone relative path matches up so CDN caches won't pick
        // up thumbs that would not be purged on source file deletion (T36231).
        if ( $rel404 !== null ) { // thumbnail was handled via 404
                if ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName 
) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a725dae551c867a4fa7c213838d52c7fb862756
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jforrester <jforres...@wikimedia.org>

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

Reply via email to