diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2019-03-14 17:23:26 -0700 |
---|---|---|
committer | James D. Forrester <jforrester@wikimedia.org> | 2019-08-06 13:45:27 -0700 |
commit | 35da1bbd7cb8b4414c4fbcf331473f1024bc638d (patch) | |
tree | f903765d437301b1bff67ebea4fd895ce64132d9 /includes/deferred/CdnCacheUpdate.php | |
parent | a6b45d2a20c9be095431ac60ba0a4f5951b5f387 (diff) | |
download | mediawikicore-35da1bbd7cb8b4414c4fbcf331473f1024bc638d.tar.gz mediawikicore-35da1bbd7cb8b4414c4fbcf331473f1024bc638d.zip |
Add small HtmlCacheUpdater service class to normalize purging code
The purge() method handles purging of both file cache and CDN, using
a PRESEND deferred update. This avoids code duplication and missing
file cache purge calls.
Also:
* Migrate HTMLCacheUpdate callers to just directly using HTMLCacheUpdateJob
* Add HtmlFileCacheUpdate class and defer such updates just like with CDN
* Simplify HTMLCacheUpdate constructor parameters
* Remove BacklinkCache::clear() calls which do nothing since the backlink
query does not actually happen until the job runs
Change-Id: Ic453b189a40109a73a9426538608eea87a76befa
Diffstat (limited to 'includes/deferred/CdnCacheUpdate.php')
-rw-r--r-- | includes/deferred/CdnCacheUpdate.php | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/includes/deferred/CdnCacheUpdate.php b/includes/deferred/CdnCacheUpdate.php index 66ce9a3ddf83..a867f2062ef4 100644 --- a/includes/deferred/CdnCacheUpdate.php +++ b/includes/deferred/CdnCacheUpdate.php @@ -24,12 +24,12 @@ use Wikimedia\Assert\Assert; use MediaWiki\MediaWikiServices; /** - * Handles purging appropriate CDN URLs given a title (or titles) + * Handles purging the appropriate CDN objects given a list of URLs or Title instances * @ingroup Cache */ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate { /** @var string[] Collection of URLs to purge */ - protected $urls = []; + private $urls = []; /** * @param string[] $urlArr Collection of URLs to purge @@ -59,12 +59,9 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate { $urlArr = array_merge( $urlArr, $title->getCdnUrls() ); } - return new CdnCacheUpdate( $urlArr ); + return new self( $urlArr ); } - /** - * Purges the list of URLs passed to the constructor. - */ public function doUpdate() { global $wgCdnReboundPurgeDelay; @@ -98,10 +95,9 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate { wfDebugLog( 'squid', __METHOD__ . ': ' . implode( ' ', $urlArr ) ); // Reliably broadcast the purge to all edge nodes - $relayer = MediaWikiServices::getInstance()->getEventRelayerGroup() - ->getRelayer( 'cdn-url-purges' ); $ts = microtime( true ); - $relayer->notifyMulti( + $relayerGroup = MediaWikiServices::getInstance()->getEventRelayerGroup(); + $relayerGroup->getRelayer( 'cdn-url-purges' )->notifyMulti( 'cdn-url-purges', array_map( function ( $url ) use ( $ts ) { |