aboutsummaryrefslogtreecommitdiffstats
path: root/includes/cache/HTMLFileCache.php
diff options
context:
space:
mode:
authorAaron Schulz <aschulz@wikimedia.org>2019-03-14 17:23:26 -0700
committerJames D. Forrester <jforrester@wikimedia.org>2019-08-06 13:45:27 -0700
commit35da1bbd7cb8b4414c4fbcf331473f1024bc638d (patch)
treef903765d437301b1bff67ebea4fd895ce64132d9 /includes/cache/HTMLFileCache.php
parenta6b45d2a20c9be095431ac60ba0a4f5951b5f387 (diff)
downloadmediawikicore-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/cache/HTMLFileCache.php')
-rw-r--r--includes/cache/HTMLFileCache.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php
index a0d61b259efd..6d0b87e6e66c 100644
--- a/includes/cache/HTMLFileCache.php
+++ b/includes/cache/HTMLFileCache.php
@@ -220,20 +220,32 @@ class HTMLFileCache extends FileCacheBase {
}
/**
+ * @param string[] $prefixedDbKeys List of prefixed DB keys for pages to purge
+ * @since 1.34
+ */
+ public static function purge( array $prefixedDbKeys ) {
+ foreach ( $prefixedDbKeys as $prefixedDbKey ) {
+ foreach ( self::cacheablePageActions() as $type ) {
+ $fc = new self( $prefixedDbKey, $type );
+ $fc->clearCache();
+ }
+ }
+ }
+
+ /**
* Clear the file caches for a page for all actions
- * @param Title $title
+ * @param Traversable|Title[]|Title $titles
* @return bool Whether $wgUseFileCache is enabled
*/
- public static function clearFileCache( Title $title ) {
+ public static function clearFileCache( $titles ) {
$config = MediaWikiServices::getInstance()->getMainConfig();
-
if ( !$config->get( 'UseFileCache' ) ) {
return false;
}
- foreach ( self::cacheablePageActions() as $type ) {
- $fc = new self( $title, $type );
- $fc->clearCache();
+ $titleIterator = ( $titles instanceof Title ) ? [ $titles ] : $titles;
+ foreach ( $titleIterator as $title ) {
+ self::purge( [ $title->getPrefixedDBkey() ] );
}
return true;