aboutsummaryrefslogtreecommitdiffstats
path: root/includes/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'includes/deferred')
-rw-r--r--includes/deferred/CdnCacheUpdate.php14
-rw-r--r--includes/deferred/HTMLCacheUpdate.php27
-rw-r--r--includes/deferred/HtmlFileCacheUpdate.php61
-rw-r--r--includes/deferred/LinksUpdate.php9
4 files changed, 83 insertions, 28 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 ) {
diff --git a/includes/deferred/HTMLCacheUpdate.php b/includes/deferred/HTMLCacheUpdate.php
index 29846bfb77f8..3dd533db7e78 100644
--- a/includes/deferred/HTMLCacheUpdate.php
+++ b/includes/deferred/HTMLCacheUpdate.php
@@ -22,39 +22,32 @@
*/
/**
- * Class to invalidate the HTML cache of all the pages linking to a given title.
+ * Class to invalidate the HTML/file cache of all the pages linking to a given title.
*
* @ingroup Cache
+ * @deprecated Since 1.34; Enqueue jobs from HTMLCacheUpdateJob::newForBacklinks instead
*/
class HTMLCacheUpdate extends DataUpdate {
/** @var Title */
- public $mTitle;
-
+ private $title;
/** @var string */
- public $mTable;
+ private $table;
/**
- * @param Title $titleTo
+ * @param Title $title
* @param string $table
- * @param string $causeAction Triggering action
- * @param string $causeAgent Triggering user
*/
- function __construct(
- Title $titleTo, $table, $causeAction = 'unknown', $causeAgent = 'unknown'
- ) {
- $this->mTitle = $titleTo;
- $this->mTable = $table;
- $this->causeAction = $causeAction;
- $this->causeAgent = $causeAgent;
+ public function __construct( Title $title, $table ) {
+ $this->title = $title;
+ $this->table = $table;
}
public function doUpdate() {
$job = HTMLCacheUpdateJob::newForBacklinks(
- $this->mTitle,
- $this->mTable,
+ $this->title,
+ $this->table,
[ 'causeAction' => $this->getCauseAction(), 'causeAgent' => $this->getCauseAgent() ]
);
-
JobQueueGroup::singleton()->lazyPush( $job );
}
}
diff --git a/includes/deferred/HtmlFileCacheUpdate.php b/includes/deferred/HtmlFileCacheUpdate.php
new file mode 100644
index 000000000000..7be8b61eaba9
--- /dev/null
+++ b/includes/deferred/HtmlFileCacheUpdate.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * HTMLFileCache cache purging
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
+
+use MediaWiki\MediaWikiServices;
+
+/**
+ * Handles purging the appropriate HTMLFileCache files given a list of titles
+ * @ingroup Cache
+ */
+class HtmlFileCacheUpdate implements DeferrableUpdate {
+ /** @var string[] Collection of prefixed DB keys for the pages to purge */
+ private $prefixedDbKeys = [];
+
+ /**
+ * @param string[] $prefixedDbKeys
+ */
+ public function __construct( array $prefixedDbKeys ) {
+ $this->prefixedDbKeys = $prefixedDbKeys;
+ }
+
+ /**
+ * Create an update object from an array of Title objects, or a TitleArray object
+ *
+ * @param Traversable|Title[] $titles
+ * @return HtmlFileCacheUpdate
+ */
+ public static function newFromTitles( $titles ) {
+ $prefixedDbKeys = [];
+ foreach ( $titles as $title ) {
+ $prefixedDbKeys[] = $title->getPrefixedDBkey();
+ }
+
+ return new self( $prefixedDbKeys );
+ }
+
+ public function doUpdate() {
+ $config = MediaWikiServices::getInstance()->getMainConfig();
+ if ( $config->get( 'UseFileCache' ) ) {
+ HTMLFileCache::purge( $this->prefixedDbKeys );
+ }
+ }
+}
diff --git a/includes/deferred/LinksUpdate.php b/includes/deferred/LinksUpdate.php
index 74e236fd4d74..ff293cb9d87c 100644
--- a/includes/deferred/LinksUpdate.php
+++ b/includes/deferred/LinksUpdate.php
@@ -1066,6 +1066,7 @@ class LinksUpdate extends DataUpdate {
private function invalidateProperties( $changed ) {
global $wgPagePropLinkInvalidations;
+ $jobs = [];
foreach ( $changed as $name => $value ) {
if ( isset( $wgPagePropLinkInvalidations[$name] ) ) {
$inv = $wgPagePropLinkInvalidations[$name];
@@ -1073,12 +1074,16 @@ class LinksUpdate extends DataUpdate {
$inv = [ $inv ];
}
foreach ( $inv as $table ) {
- DeferredUpdates::addUpdate(
- new HTMLCacheUpdate( $this->mTitle, $table, 'page-props' )
+ $jobs[] = HTMLCacheUpdateJob::newForBacklinks(
+ $this->mTitle,
+ $table,
+ [ 'causeAction' => 'page-props' ]
);
}
}
}
+
+ JobQueueGroup::singleton()->lazyPush( $jobs );
}
/**