From f9f8dff40f0e2a50b617086c0a9915d8f8fbc2d7 Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Wed, 1 Nov 2017 13:55:24 -0700 Subject: [PATCH] Rename CDN config variables to be generic, deprecating the old names Hook, methods, classes still to rename where appropriate. Bug: T104148 Depends-On: Id34339dff88bc6d1863378ac94b96b2d590b891d Depends-On: I4e2938395bcbf7956b83fff00978f09c61dcfa36 Change-Id: I7a725dae551c867a4fa7c213838d52c7fb862756 --- RELEASE-NOTES-1.34 | 7 +++ includes/AjaxResponse.php | 3 +- includes/Block.php | 4 +- includes/DefaultSettings.php | 34 +++++++++----- includes/MediaWiki.php | 4 +- includes/OutputPage.php | 14 +++--- includes/ServiceWiring.php | 4 +- includes/Setup.php | 54 +++++++++++++++++++++- includes/actions/RawAction.php | 2 +- includes/api/ApiMain.php | 12 +++-- includes/clientpool/SquidPurgeClient.php | 2 +- includes/deferred/CdnCacheUpdate.php | 20 ++++---- maintenance/benchmarks/benchmarkPurge.php | 21 +++++---- maintenance/purgeChangedPages.php | 6 +-- maintenance/purgeList.php | 8 ++-- opensearch_desc.php | 2 +- tests/phpunit/includes/OutputPageTest.php | 8 ++-- tests/phpunit/includes/WebRequestTest.php | 8 ++-- tests/phpunit/includes/api/ApiMainTest.php | 16 +++---- thumb.php | 2 +- 20 files changed, 151 insertions(+), 80 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 197d9830fc..ee57d0445e 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -35,6 +35,13 @@ For notes on 1.33.x and older releases, see HISTORY. module or will be generated by Mediawiki itself (depending on the set-up). ==== Changed configuration ==== +* $wgUseCdn, $wgCdnServers, $wgCdnServersNoPurge, and $wgCdnMaxAge – These four + CDN-related config variables have been renamed from being specific to Squid – + they were previously $wgUseSquid, $wgSquidServers, $wgSquidServersNoPurge, and + $wgSquidMaxage respectively. This aligns them with the related existing + variable $wgCdnMaxageLagged. The previous configuration variable names are + deprecated, but will be used as the fall back if they are still set. + Note that wgSquidPurgeUseHostHeader has not been renamed, as it is deprecated. * … ==== Removed configuration ==== diff --git a/includes/AjaxResponse.php b/includes/AjaxResponse.php index 5f889adb86..323c5d30ac 100644 --- a/includes/AjaxResponse.php +++ b/includes/AjaxResponse.php @@ -179,8 +179,7 @@ class AjaxResponse { # If CDN caches are configured, tell them to cache the response, # 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' ) ) { + if ( $this->mConfig->get( 'UseCdn' ) ) { # 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 diff --git a/includes/Block.php b/includes/Block.php index 9f7f77d439..09069c0b08 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -1154,7 +1154,7 @@ class Block extends AbstractBlock { 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; } @@ -1215,7 +1215,7 @@ class Block extends AbstractBlock { * @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 de94f77cbb..eed732bac6 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2701,7 +2701,8 @@ $wgExtensionInfoMTime = false; * @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 @@ -2713,8 +2714,10 @@ $wgExtensionInfoMTime = false; /** * Enable/disable CDN. * See https://www.mediawiki.org/wiki/Manual:Squid_caching + * + * @since 1.34 Renamed from $wgUseSquid. */ -$wgUseSquid = false; +$wgUseCdn = false; /** * If you run Squid3 with ESI support, enable this (default:false): @@ -2756,12 +2759,15 @@ $wgInternalServer = false; * out s-maxage in the CDN config. * * 18000 seconds = 5 hours, more cache hits with 2678400 = 31 days. + * + * @since 1.34 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; @@ -2784,7 +2790,7 @@ $wgCdnReboundPurgeDelay = 0; /** * 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; @@ -2803,20 +2809,24 @@ $wgForcedRawSMaxage = 300; * 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.34 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.34 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 @@ -6505,7 +6515,7 @@ $wgCachePrefix = false; /** * 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 69bafafb7f..7b9a2d7c21 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -486,14 +486,14 @@ class MediaWiki { } # Let CDN cache things if we can purge them. - if ( $this->config->get( 'UseSquid' ) && + if ( $this->config->get( 'UseCdn' ) && 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( $this->config->get( 'CdnMaxAge' ) ); } $action->show(); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index edffc3bd03..54b3ee5f68 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -746,10 +746,10 @@ class OutputPage extends ContextSource { 'user' => $this->getUser()->getTouched(), 'epoch' => $config->get( 'CacheEpoch' ) ]; - if ( $config->get( 'UseSquid' ) ) { + if ( $config->get( 'UseCdn' ) ) { $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, $this->getCdnCacheEpoch( time(), - $config->get( 'SquidMaxage' ) + $config->get( 'CdnMaxAge' ) ) ); } Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, $this ] ); @@ -818,7 +818,7 @@ class OutputPage extends ContextSource { * @return int Timestamp */ private function getCdnCacheEpoch( $reqTime, $maxAge ) { - // Ensure Last-Modified is never more than (wgSquidMaxage) in the past, + // Ensure Last-Modified is never more than $wgCdnMaxAge in the past, // because even if the wiki page content hasn't changed since, static // resources may have changed (skin HTML, interface messages, urls, etc.) // and must roll-over in a timely manner (T46570) @@ -2248,12 +2248,12 @@ class OutputPage extends ContextSource { * * @param string|int|float|bool|null $mtime Last-Modified timestamp * @param int $minTTL Minimum TTL in seconds [default: 1 minute] - * @param int $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage] + * @param int $maxTTL Maximum TTL in seconds [default: $wgCdnMaxAge] * @since 1.28 */ public function adaptCdnTTL( $mtime, $minTTL = 0, $maxTTL = 0 ) { $minTTL = $minTTL ?: IExpiringStore::TTL_MINUTE; - $maxTTL = $maxTTL ?: $this->getConfig()->get( 'SquidMaxage' ); + $maxTTL = $maxTTL ?: $this->getConfig()->get( 'CdnMaxAge' ); if ( $mtime === null || $mtime === false ) { return $minTTL; // entity does not exist @@ -2567,7 +2567,7 @@ class OutputPage extends ContextSource { if ( $this->mEnableClientCache ) { if ( - $config->get( 'UseSquid' ) && + $config->get( 'UseCdn' ) && !$response->hasCookies() && !SessionManager::getGlobalSession()->isPersistent() && !$this->isPrintable() && @@ -2584,7 +2584,7 @@ class OutputPage extends ContextSource { # 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={$config->get( 'CdnMaxAge' )}" . "+{$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 c9db5a88dc..c5764d2262 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -484,8 +484,8 @@ return [ 'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup { $mainConfig = $services->getMainConfig(); return new ProxyLookup( - $mainConfig->get( 'SquidServers' ), - $mainConfig->get( 'SquidServersNoPurge' ) + $mainConfig->get( 'CdnServers' ), + $mainConfig->get( 'CdnServersNoPurge' ) ); }, diff --git a/includes/Setup.php b/includes/Setup.php index a51cb83c19..f367fc2278 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -518,9 +518,61 @@ foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) // To determine the user language, use $wgLang->getCode() $wgContLanguageCode = $wgLanguageCode; +// Temporary backwards-compatibility reading of old Squid-named CDN settings as of MediaWiki 1.34, +// to support sysadmins who fail to update their settings immediately: + +if ( isset( $wgUseSquid ) ) { + // If the sysadmin is still setting a value of $wgUseSquid to true but $wgUseCdn is the default of + // false, to be safe, assume they do want this still, so enable it. + if ( !$wgUseCdn && $wgUseSquid ) { + $wgUseCdn = $wgUseSquid; + wfDeprecated( '$wgUseSquid enabled but $wgUseCdn disabled; enabling CDN functions', '1.34' ); + } +} else { + // Backwards-compatibility for extensions that read this value. + $wgUseSquid = $wgUseCdn; +} + +if ( isset( $wgSquidServers ) ) { + // If the sysadmin is still setting a value of $wgSquidServers but $wgCdnServers is the default of + // empty, to be safe, assume they do want these servers to be still used, so use them. + if ( !empty( $wgSquidServers ) && empty( $wgCdnServers ) ) { + $wgCdnServers = $wgSquidServers; + wfDeprecated( '$wgSquidServers set, $wgCdnServers empty; using them', '1.34' ); + } +} else { + // Backwards-compatibility for extensions that read this value. + $wgSquidServers = $wgCdnServers; +} + +if ( isset( $wgSquidServersNoPurge ) ) { + // If the sysadmin is still setting values in $wgSquidServersNoPurge but $wgCdnServersNoPurge is + // the default of empty, to be safe, assume they do want these servers to be still used, so use + // them. + if ( !empty( $wgSquidServersNoPurge ) && empty( $wgCdnServersNoPurge ) ) { + $wgCdnServersNoPurge = $wgSquidServersNoPurge; + wfDeprecated( '$wgSquidServersNoPurge set, $wgCdnServersNoPurge empty; using them', '1.34' ); + } +} else { + // Backwards-compatibility for extensions that read this value. + $wgSquidServersNoPurge = $wgCdnServersNoPurge; +} + +if ( isset( $wgSquidMaxage ) ) { + // If the sysadmin is still setting a value of $wgSquidMaxage and it's higher than $wgCdnMaxAge, + // to be safe, assume they want the higher (lower performance requirement) value, so use that. + if ( $wgCdnMaxAge < $wgSquidMaxage ) { + $wgCdnMaxAge = $wgSquidMaxage; + wfDeprecated( '$wgSquidMaxage set higher than $wgCdnMaxAge; using the higher value', '1.34' ); + } +} else { + // Backwards-compatibility for extensions that read this value. + $wgSquidMaxage = $wgCdnMaxAge; +} + // Easy to forget to falsify $wgDebugToolbar for static caches. // If file cache or CDN cache is on, just disable this (DWIMD). -if ( $wgUseFileCache || $wgUseSquid ) { +if ( $wgUseFileCache || $wgUseCdn ) { $wgDebugToolbar = false; } diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index 14f7603785..505c9d5dc2 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -67,7 +67,7 @@ class RawAction extends FormlessAction { $contentType = $this->getContentType(); - $maxage = $request->getInt( 'maxage', $config->get( 'SquidMaxage' ) ); + $maxage = $request->getInt( 'maxage', $config->get( 'CdnMaxAge' ) ); $smaxage = $request->getIntOrNull( 'smaxage' ); if ( $smaxage === null ) { if ( diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 1a7175a3e0..b845c57b58 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -148,7 +148,7 @@ class ApiMain extends ApiBase { private $mContinuationManager; private $mAction; private $mEnableWrite; - private $mInternalMode, $mSquidMaxage; + private $mInternalMode, $mCdnMaxAge; /** @var ApiBase */ private $mModule; @@ -288,7 +288,7 @@ class ApiMain extends ApiBase { $this->mContinuationManager = null; $this->mEnableWrite = $enableWrite; - $this->mSquidMaxage = -1; // flag for executeActionWithErrorHandling() + $this->mCdnMaxAge = -1; // flag for executeActionWithErrorHandling() $this->mCommit = false; } @@ -1368,18 +1368,20 @@ class ApiMain extends ApiBase { $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' ) ) { + + if ( $config->get( 'UseCdn' ) ) { // T46570: the core page itself may not change, but resources might $modifiedTimes['sepoch'] = wfTimestamp( - TS_MW, time() - $this->getConfig()->get( 'SquidMaxage' ) + TS_MW, time() - $config->get( 'CdnMaxAge' ) ); } Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, $this->getOutput() ] ); diff --git a/includes/clientpool/SquidPurgeClient.php b/includes/clientpool/SquidPurgeClient.php index 75f51ef7e3..6b5482cf8d 100644 --- a/includes/clientpool/SquidPurgeClient.php +++ b/includes/clientpool/SquidPurgeClient.php @@ -150,7 +150,7 @@ class SquidPurgeClient { 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 { Wikimedia\suppressWarnings(); $this->ip = gethostbyname( $this->host ); diff --git a/includes/deferred/CdnCacheUpdate.php b/includes/deferred/CdnCacheUpdate.php index 2d07f75156..66ce9a3ddf 100644 --- a/includes/deferred/CdnCacheUpdate.php +++ b/includes/deferred/CdnCacheUpdate.php @@ -79,14 +79,14 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate { } /** - * 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, $wgHTCPRouting; if ( !$urlArr ) { return; @@ -120,20 +120,20 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate { } // Do direct server purges if enabled (this does not scale very well) - if ( $wgSquidServers ) { - // Maximum number of parallel connections per squid - $maxSocketsPerSquid = 8; + if ( $wgCdnServers ) { + // 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 ( $wgCdnServers as $server ) { foreach ( $chunks as $chunk ) { $client = new SquidPurgeClient( $server ); foreach ( $chunk as $url ) { diff --git a/maintenance/benchmarks/benchmarkPurge.php b/maintenance/benchmarks/benchmarkPurge.php index e681a0498e..bb41a91093 100644 --- a/maintenance/benchmarks/benchmarkPurge.php +++ b/maintenance/benchmarks/benchmarkPurge.php @@ -1,6 +1,6 @@ addDescription( 'Benchmark the Squid purge functions.' ); + $this->addDescription( 'Benchmark the CDN purge functions.' ); } public function execute() { - global $wgUseSquid, $wgSquidServers; - if ( !$wgUseSquid ) { - $this->fatalError( "Squid purge benchmark doesn't do much without squid support on." ); + global $wgUseCdn, $wgCdnServers; + + if ( !$wgUseCdn ) { + $this->error( "CDN purge benchmark doesn't do much without CDN support on." ); } else { - $this->output( "There are " . count( $wgSquidServers ) . " defined squid servers:\n" ); + $this->output( "There are " . count( $wgCdnServers ) . " defined CDN servers:\n" ); if ( $this->hasOption( 'count' ) ) { $lengths = [ intval( $this->getOption( 'count' ) ) ]; } else { @@ -47,7 +48,7 @@ class BenchmarkPurge extends Benchmarker { } foreach ( $lengths as $length ) { $urls = $this->randomUrlList( $length ); - $trial = $this->benchSquid( $urls ); + $trial = $this->benchCdn( $urls ); $this->output( $trial . "\n" ); } } @@ -55,12 +56,12 @@ class BenchmarkPurge extends Benchmarker { /** * Run a bunch of URLs through CdnCacheUpdate::purge() - * to benchmark Squid response times. + * 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/maintenance/purgeChangedPages.php b/maintenance/purgeChangedPages.php index 81fb5e39d7..8f47b1605f 100644 --- a/maintenance/purgeChangedPages.php +++ b/maintenance/purgeChangedPages.php @@ -136,9 +136,9 @@ class PurgeChangedPages extends Maintenance { } } - // Send batch of purge requests out to squids - $squid = new CdnCacheUpdate( $urls, count( $urls ) ); - $squid->doUpdate(); + // Send batch of purge requests out to CDN servers + $cdn = new CdnCacheUpdate( $urls, count( $urls ) ); + $cdn->doUpdate(); if ( $this->hasOption( 'sleep-per-batch' ) ) { // sleep-per-batch is milliseconds, usleep wants micro seconds. diff --git a/maintenance/purgeList.php b/maintenance/purgeList.php index 16a62f405d..d558c478e8 100644 --- a/maintenance/purgeList.php +++ b/maintenance/purgeList.php @@ -1,6 +1,6 @@ addDescription( 'Send purge requests for listed pages to squid' ); + $this->addDescription( 'Send purge requests for listed pages to CDN' ); $this->addOption( 'purge', 'Whether to update page_touched.', false, false ); $this->addOption( 'namespace', 'Namespace number', false, true ); $this->addOption( 'all', 'Purge all pages', false, false ); @@ -120,7 +120,7 @@ class PurgeList extends Maintenance { /** * Helper to purge an array of $urls - * @param array $urls List of URLS to purge from squids + * @param array $urls List of URLS to purge from CDNs */ private function sendPurgeRequest( $urls ) { if ( $this->hasOption( 'delay' ) ) { diff --git a/opensearch_desc.php b/opensearch_desc.php index bd3281aa9c..15ec62d0e5 100644 --- a/opensearch_desc.php +++ b/opensearch_desc.php @@ -36,7 +36,7 @@ if ( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) { $response = $wgRequest->response(); $response->header( "Content-type: $ctype" ); -// Set an Expires header so that squid can cache it for a short time +// Set an Expires header so that CDN can cache it for a short time // Short enough so that the sysadmin barely notices when $wgSitename is changed $expiryTime = 600; # 10 minutes $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' ); diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index afc6bb582d..ebd9f1d068 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -526,9 +526,9 @@ class OutputPageTest extends MediaWikiTestCase { function ( $op ) { $op->getContext()->setUser( $this->getTestUser()->getUser() ); } ], - 'After Squid expiry' => + 'After CDN expiry' => [ $lastModified, $lastModified, false, - [ 'UseSquid' => true, 'SquidMaxage' => 3599 ] ], + [ 'UseCdn' => true, 'CdnMaxAge' => 3599 ] ], 'Hook allows cache use' => [ $lastModified + 1, $lastModified, true, [], function ( $op, $that ) { @@ -2225,7 +2225,7 @@ class OutputPageTest extends MediaWikiTestCase { } public function provideAdaptCdnTTL() { - global $wgSquidMaxage; + global $wgCdnMaxAge; $now = time(); self::$fakeTime = $now; return [ @@ -2234,7 +2234,7 @@ class OutputPageTest extends MediaWikiTestCase { 'Five minutes from now' => [ [ $now + 300 ], IExpiringStore::TTL_MINUTE ], 'Five minutes ago, initial maxage four minutes' => [ [ $now - 300 ], 270, [ 'initialMaxage' => 240 ] ], - 'A very long time ago' => [ [ $now - 1000000000 ], $wgSquidMaxage ], + 'A very long time ago' => [ [ $now - 1000000000 ], $wgCdnMaxAge ], 'Initial maxage zero' => [ [ $now - 300 ], 270, [ 'initialMaxage' => 0 ] ], 'false' => [ [ false ], IExpiringStore::TTL_MINUTE ], diff --git a/tests/phpunit/includes/WebRequestTest.php b/tests/phpunit/includes/WebRequestTest.php index cda56603f9..0d5c59b0de 100644 --- a/tests/phpunit/includes/WebRequestTest.php +++ b/tests/phpunit/includes/WebRequestTest.php @@ -391,7 +391,7 @@ class WebRequestTest extends MediaWikiTestCase { * @dataProvider provideGetIP * @covers WebRequest::getIP */ - public function testGetIP( $expected, $input, $squid, $xffList, $private, $description ) { + public function testGetIP( $expected, $input, $cdn, $xffList, $private, $description ) { $this->setServerVars( $input ); $this->setMwGlobals( [ 'wgUsePrivateIPs' => $private, @@ -405,7 +405,7 @@ class WebRequestTest extends MediaWikiTestCase { ] ] ); - $this->setService( 'ProxyLookup', new ProxyLookup( [], $squid ) ); + $this->setService( 'ProxyLookup', new ProxyLookup( [], $cdn ) ); $request = new WebRequest(); $result = $request->getIP(); @@ -587,8 +587,8 @@ class WebRequestTest extends MediaWikiTestCase { 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/tests/phpunit/includes/api/ApiMainTest.php b/tests/phpunit/includes/api/ApiMainTest.php index 9cb84e23bc..a5518a1252 100644 --- a/tests/phpunit/includes/api/ApiMainTest.php +++ b/tests/phpunit/includes/api/ApiMainTest.php @@ -490,7 +490,7 @@ class ApiMainTest extends ApiTestCase { * @param int $status Expected response status * @param array $options Array of options: * post => true Request is a POST - * cdn => true CDN is enabled ($wgUseSquid) + * cdn => true CDN is enabled ($wgUseCdn) */ public function testCheckConditionalRequestHeaders( $headers, $conditions, $status, $options = [] @@ -508,7 +508,7 @@ class ApiMainTest extends ApiTestCase { $priv->mInternalMode = false; if ( !empty( $options['cdn'] ) ) { - $this->setMwGlobals( 'wgUseSquid', true ); + $this->setMwGlobals( 'wgUseCdn', true ); } // Can't do this in TestSetup.php because Setup.php will override it @@ -531,7 +531,7 @@ class ApiMainTest extends ApiTestCase { } public static function provideCheckConditionalRequestHeaders() { - global $wgSquidMaxage; + global $wgCdnMaxAge; $now = time(); return [ @@ -614,15 +614,15 @@ class ApiMainTest extends ApiTestCase { [ [ 'If-Modified-Since' => 'a potato' ], [ 'last-modified' => wfTimestamp( TS_MW, $now - 1 ) ], 200 ], - // Anything before $wgSquidMaxage seconds ago should be considered + // Anything before $wgCdnMaxAge seconds ago should be considered // expired. 'If-Modified-Since with CDN post-expiry' => - [ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgSquidMaxage * 2 ) ], - [ 'last-modified' => wfTimestamp( TS_MW, $now - $wgSquidMaxage * 3 ) ], + [ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgCdnMaxAge * 2 ) ], + [ 'last-modified' => wfTimestamp( TS_MW, $now - $wgCdnMaxAge * 3 ) ], 200, [ 'cdn' => true ] ], 'If-Modified-Since with CDN pre-expiry' => - [ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgSquidMaxage / 2 ) ], - [ 'last-modified' => wfTimestamp( TS_MW, $now - $wgSquidMaxage * 3 ) ], + [ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgCdnMaxAge / 2 ) ], + [ 'last-modified' => wfTimestamp( TS_MW, $now - $wgCdnMaxAge * 3 ) ], 304, [ 'cdn' => true ] ], ]; } diff --git a/thumb.php b/thumb.php index 70329093c6..43dd5d472f 100644 --- a/thumb.php +++ b/thumb.php @@ -272,7 +272,7 @@ function wfStreamThumb( array $params ) { // 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 ) ) { -- 2.20.1