From f606fd8d5c0c7a601be75a5992375d60520a12f8 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 9 Dec 2015 17:07:05 -0800 Subject: [PATCH] Rename setSquidMaxage() => setCdnMaxage() Also updated the OutputPage member variable. Change-Id: I0b41c66da58c6126c1bd96170c02d084a067383c --- includes/MediaWiki.php | 4 ++-- includes/OutputPage.php | 28 ++++++++++++++-------- includes/page/Article.php | 2 +- includes/skins/Skin.php | 4 ++-- includes/specials/SpecialRecentchanges.php | 2 +- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index c4ea536436..50f2dadf8d 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -308,7 +308,7 @@ class MediaWiki { $targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); if ( $targetUrl != $request->getFullRequestURL() ) { - $output->setSquidMaxage( 1200 ); + $output->setCdnMaxage( 1200 ); $output->redirect( $targetUrl, '301' ); return true; } @@ -451,7 +451,7 @@ class MediaWiki { $requestTitle->getSquidURLs() ) ) { - $output->setSquidMaxage( $this->config->get( 'SquidMaxage' ) ); + $output->setCdnMaxage( $this->config->get( 'SquidMaxage' ) ); } $action->show(); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 00143c76f8..b7f5558b50 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -233,8 +233,8 @@ class OutputPage extends ContextSource { private $mParseWarnings = array(); /** @var int Cache stuff. Looks like mEnableClientCache */ - protected $mSquidMaxage = 0; - /** @var int Upper limit on mSquidMaxage */ + protected $mCdnMaxage = 0; + /** @var int Upper limit on mCdnMaxage */ protected $mCdnMaxageLimit = INF; /** @@ -1943,24 +1943,32 @@ class OutputPage extends ContextSource { return Parser::stripOuterParagraph( $parsed ); } + /** + * @param $maxage + * @deprecated since 1.27 Use setCdnMaxage() instead + */ + public function setSquidMaxage( $maxage ) { + $this->setCdnMaxage( $maxage ); + } + /** * Set the value of the "s-maxage" part of the "Cache-control" HTTP header * - * @param int $maxage Maximum cache time on the Squid, in seconds. + * @param int $maxage Maximum cache time on the CDN, in seconds. */ - public function setSquidMaxage( $maxage ) { - $this->mSquidMaxage = min( $maxage, $this->mCdnMaxageLimit ); + public function setCdnMaxage( $maxage ) { + $this->mCdnMaxage = min( $maxage, $this->mCdnMaxageLimit ); } /** * Lower the value of the "s-maxage" part of the "Cache-control" HTTP header * - * @param int $maxage Maximum cache time on the Squid, in seconds + * @param int $maxage Maximum cache time on the CDN, in seconds * @since 1.27 */ public function lowerCdnMaxage( $maxage ) { $this->mCdnMaxageLimit = min( $maxage, $this->mCdnMaxageLimit ); - $this->setSquidMaxage( $this->mSquidMaxage ); + $this->setCdnMaxage( $this->mCdnMaxage ); } /** @@ -2181,7 +2189,7 @@ class OutputPage extends ContextSource { if ( $this->mEnableClientCache ) { if ( $config->get( 'UseSquid' ) && session_id() == '' && !$this->isPrintable() && - $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies() + $this->mCdnMaxage != 0 && !$this->haveCacheVaryCookies() ) { if ( $config->get( 'UseESI' ) ) { # We'll purge the proxy cache explicitly, but require end user agents @@ -2191,7 +2199,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' ) - . '+' . $this->mSquidMaxage . ', content="ESI/1.0"' ); + . '+' . $this->mCdnMaxage . ', content="ESI/1.0"' ); $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' ); } else { # We'll purge the proxy cache for anons explicitly, but require end user agents @@ -2201,7 +2209,7 @@ class OutputPage extends ContextSource { wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **\n", 'log' ); # start with a shorter timeout for initial testing # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" ); - $response->header( 'Cache-Control: s-maxage=' . $this->mSquidMaxage + $response->header( 'Cache-Control: s-maxage=' . $this->mCdnMaxage . ', must-revalidate, max-age=0' ); } } else { diff --git a/includes/page/Article.php b/includes/page/Article.php index 5d6435ee5c..35621a4ddc 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -696,7 +696,7 @@ class Article implements Page { # Don't cache a dirty ParserOutput object if ( $poolArticleView->getIsDirty() ) { - $outputPage->setSquidMaxage( 0 ); + $outputPage->setCdnMaxage( 0 ); $outputPage->addHTML( "\n" ); } diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 81773712d4..a6a6814f06 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -1446,7 +1446,7 @@ abstract class Skin extends ContextSource { } $newMessagesAlert = $newMessagesAlert->text(); # Disable Squid cache - $out->setSquidMaxage( 0 ); + $out->setCdnMaxage( 0 ); } elseif ( count( $newtalks ) ) { $sep = $this->msg( 'newtalkseparator' )->escaped(); $msgs = array(); @@ -1459,7 +1459,7 @@ abstract class Skin extends ContextSource { } $parts = implode( $sep, $msgs ); $newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped(); - $out->setSquidMaxage( 0 ); + $out->setCdnMaxage( 0 ); } return $newMessagesAlert; diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 44c99877aa..3a1621ab9c 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -50,7 +50,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { } // 10 seconds server-side caching max - $this->getOutput()->setSquidMaxage( 10 ); + $this->getOutput()->setCdnMaxage( 10 ); // Check if the client has a cached version $lastmod = $this->checkLastModified(); if ( $lastmod === false ) { -- 2.20.1