From f4a306fb18f1d52b5bd8acef8391b157258418f8 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 1 Feb 2017 10:12:14 -0500 Subject: [PATCH] Deprecate "Avoid page_touched update for HTTP GET action=purge requests" This reverts most of commit c84ba4d86420d7af918e572e2cd4613d7be185b3. The changes made there are no longer needed, and nothing in Gerrit seems to have started using them since they were added. The added constants in WikiPage, WikiPage::getLastPurgeTimestamp(), and Article::getLastPurgeTimestamp() are deprecated, useless, and unused, but not removed yet since they snuck into 1.28 so we can't revert them without a deprecation period. Sigh. Bug: T145649 Change-Id: I526fd4e004bee84c831a4cee71e44e92ee73480b --- RELEASE-NOTES-1.29 | 3 ++ includes/actions/PurgeAction.php | 2 +- includes/actions/ViewAction.php | 3 -- includes/api/ApiPurge.php | 2 +- includes/page/Article.php | 8 ++++-- includes/page/WikiFilePage.php | 10 ++++--- includes/page/WikiPage.php | 49 ++++++++++++-------------------- 7 files changed, 35 insertions(+), 42 deletions(-) diff --git a/RELEASE-NOTES-1.29 b/RELEASE-NOTES-1.29 index bd75eb7168..c87e90cee2 100644 --- a/RELEASE-NOTES-1.29 +++ b/RELEASE-NOTES-1.29 @@ -268,6 +268,9 @@ changes to languages because of Phabricator reports. * WikiRevision::$fileIsTemp was deprecated. * WikiRevision::$importer was deprecated. * WikiRevision::$user was deprecated. +* Article::getLastPurgeTimestamp(), WikiPage::getLastPurgeTimestamp(), and the + WikiPage::PURGE_* constants are deprecated, and the functions will always + return false. They were a hack for an issue that has since been fixed. == Compatibility == diff --git a/includes/actions/PurgeAction.php b/includes/actions/PurgeAction.php index 942b731634..b2002ffae9 100644 --- a/includes/actions/PurgeAction.php +++ b/includes/actions/PurgeAction.php @@ -42,7 +42,7 @@ class PurgeAction extends FormAction { } public function onSubmit( $data ) { - return $this->page->doPurge( WikiPage::PURGE_ALL ); + return $this->page->doPurge(); } public function show() { diff --git a/includes/actions/ViewAction.php b/includes/actions/ViewAction.php index 0ba964f9b1..134b8a45b1 100644 --- a/includes/actions/ViewAction.php +++ b/includes/actions/ViewAction.php @@ -58,9 +58,6 @@ class ViewAction extends FormlessAction { $touched = null; } - // If a page was purged on HTTP GET, relect that timestamp to avoid sending 304s - $touched = max( $touched, $this->page->getLastPurgeTimestamp() ); - // Send HTTP 304 if the IMS matches or otherwise set expiry/last-modified headers if ( $touched && $this->getOutput()->checkLastModified( $touched ) ) { wfDebug( __METHOD__ . ": done 304\n" ); diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php index 312463835c..407497e67e 100644 --- a/includes/api/ApiPurge.php +++ b/includes/api/ApiPurge.php @@ -56,7 +56,7 @@ class ApiPurge extends ApiBase { $page = WikiPage::factory( $title ); if ( !$user->pingLimiter( 'purge' ) ) { // Directly purge and skip the UI part of purge() - $page->doPurge( WikiPage::PURGE_ALL ); + $page->doPurge(); $r['purged'] = true; } else { $this->addWarning( 'apierror-ratelimited' ); diff --git a/includes/page/Article.php b/includes/page/Article.php index cb97126ba3..60676490c4 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -2043,16 +2043,20 @@ class Article implements Page { /** * Call to WikiPage function for backwards compatibility. * @see WikiPage::doPurge + * @note In 1.28 (and only 1.28), this took a $flags parameter that + * controlled how much purging was done. */ - public function doPurge( $flags = WikiPage::PURGE_ALL ) { - return $this->mPage->doPurge( $flags ); + public function doPurge() { + return $this->mPage->doPurge(); } /** * Call to WikiPage function for backwards compatibility. * @see WikiPage::getLastPurgeTimestamp + * @deprecated since 1.29 */ public function getLastPurgeTimestamp() { + wfDeprecated( __METHOD__, '1.29' ); return $this->mPage->getLastPurgeTimestamp(); } diff --git a/includes/page/WikiFilePage.php b/includes/page/WikiFilePage.php index e4b524b811..66fadf5eed 100644 --- a/includes/page/WikiFilePage.php +++ b/includes/page/WikiFilePage.php @@ -164,9 +164,12 @@ class WikiFilePage extends WikiPage { return $this->mDupes; } - public function doPurge( $flags = self::PURGE_ALL ) { + /** + * Override handling of action=purge + * @return bool + */ + public function doPurge() { $this->loadFile(); - if ( $this->mFile->exists() ) { wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" ); DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ) ); @@ -182,8 +185,7 @@ class WikiFilePage extends WikiPage { // Purge redirect cache $this->mRepo->invalidateImageRedirect( $this->mTitle ); } - - return parent::doPurge( $flags ); + return parent::doPurge(); } /** diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 4bc8ad6125..a99feaf116 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -84,9 +84,10 @@ class WikiPage implements Page, IDBAccessObject { */ protected $mLinksUpdated = '19700101000000'; - const PURGE_CDN_CACHE = 1; // purge CDN cache for page variant URLs - const PURGE_CLUSTER_PCACHE = 2; // purge parser cache in the local datacenter - const PURGE_GLOBAL_PCACHE = 4; // set page_touched to clear parser cache in all datacenters + /** @deprecated since 1.29. Added in 1.28 for partial purging, no longer used. */ + const PURGE_CDN_CACHE = 1; + const PURGE_CLUSTER_PCACHE = 2; + const PURGE_GLOBAL_PCACHE = 4; const PURGE_ALL = 7; /** @@ -1119,10 +1120,11 @@ class WikiPage implements Page, IDBAccessObject { /** * Perform the actions of a page purging - * @param integer $flags Bitfield of WikiPage::PURGE_* constants * @return bool + * @note In 1.28 (and only 1.28), this took a $flags parameter that + * controlled how much purging was done. */ - public function doPurge( $flags = self::PURGE_ALL ) { + public function doPurge() { // Avoid PHP 7.1 warning of passing $this by reference $wikiPage = $this; @@ -1130,30 +1132,15 @@ class WikiPage implements Page, IDBAccessObject { return false; } - if ( ( $flags & self::PURGE_GLOBAL_PCACHE ) == self::PURGE_GLOBAL_PCACHE ) { - // Set page_touched in the database to invalidate all DC caches - $this->mTitle->invalidateCache(); - } elseif ( ( $flags & self::PURGE_CLUSTER_PCACHE ) == self::PURGE_CLUSTER_PCACHE ) { - // Delete the parser options key in the local cluster to invalidate the DC cache - ParserCache::singleton()->deleteOptionsKey( $this ); - // Avoid sending HTTP 304s in ViewAction to the client who just issued the purge - $cache = ObjectCache::getLocalClusterInstance(); - $cache->set( - $cache->makeKey( 'page', 'last-dc-purge', $this->getId() ), - wfTimestamp( TS_MW ), - $cache::TTL_HOUR - ); - } + $this->mTitle->invalidateCache(); - if ( ( $flags & self::PURGE_CDN_CACHE ) == self::PURGE_CDN_CACHE ) { - // Clear any HTML file cache - HTMLFileCache::clearFileCache( $this->getTitle() ); - // Send purge after any page_touched above update was committed - DeferredUpdates::addUpdate( - new CdnCacheUpdate( $this->mTitle->getCdnUrls() ), - DeferredUpdates::PRESEND - ); - } + // Clear file cache + HTMLFileCache::clearFileCache( $this->getTitle() ); + // Send purge after above page_touched update was committed + DeferredUpdates::addUpdate( + new CdnCacheUpdate( $this->mTitle->getCdnUrls() ), + DeferredUpdates::PRESEND + ); if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { $messageCache = MessageCache::singleton(); @@ -1168,11 +1155,11 @@ class WikiPage implements Page, IDBAccessObject { * * @return string|bool TS_MW timestamp or false * @since 1.28 + * @deprecated since 1.29. It will always return false. */ public function getLastPurgeTimestamp() { - $cache = ObjectCache::getLocalClusterInstance(); - - return $cache->get( $cache->makeKey( 'page', 'last-dc-purge', $this->getId() ) ); + wfDeprecated( __METHOD__, '1.29' ); + return false; } /** -- 2.20.1