* on the number of links. Typically called on create and delete.
*/
public function touchLinks() {
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks' ) );
+ DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks', 'page-touch' ) );
if ( $this->getNamespace() == NS_CATEGORY ) {
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'categorylinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $this, 'categorylinks', 'category-touch' )
+ );
}
}
*
* @ingroup Cache
*/
-class HTMLCacheUpdate implements DeferrableUpdate {
+class HTMLCacheUpdate extends DataUpdate {
/** @var Title */
public $mTitle;
/**
* @param Title $titleTo
* @param string $table
+ * @param string $causeAction Triggering action
+ * @param string $causeAgent Triggering user
*/
- function __construct( Title $titleTo, $table ) {
+ function __construct(
+ Title $titleTo, $table, $causeAction = 'unknown', $causeAgent = 'unknown'
+ ) {
$this->mTitle = $titleTo;
$this->mTable = $table;
+ $this->causeAction = $causeAction;
+ $this->causeAgent = $causeAgent;
}
public function doUpdate() {
- $job = HTMLCacheUpdateJob::newForBacklinks( $this->mTitle, $this->mTable );
+ $job = HTMLCacheUpdateJob::newForBacklinks(
+ $this->mTitle,
+ $this->mTable,
+ [ 'causeAction' => $this->getCauseAction(), 'causeAgent' => $this->getCauseAgent() ]
+ );
JobQueueGroup::singleton()->lazyPush( $job );
}
$inv = [ $inv ];
}
foreach ( $inv as $table ) {
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $this->mTitle, $table, 'page-props' )
+ );
}
}
}
// Purge cache of all pages using this file
$title = $this->getTitle();
if ( $title ) {
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $title, 'imagelinks', 'file-purge' )
+ );
}
}
}
# Invalidate cache for all pages using this file
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $this->getTitle(), 'imagelinks', 'file-upload' )
+ );
return Status::newGood();
}
// Multiple pages per job make matches unlikely
!( isset( $params['pages'] ) && count( $params['pages'] ) != 1 )
);
+ $this->params += [ 'causeAction' => 'unknown', 'causeAgent' => 'unknown' ];
}
/**
* @param Title $title Title to purge backlink pages from
* @param string $table Backlink table name
+ * @param array $params Additional job parameters
* @return HTMLCacheUpdateJob
*/
- public static function newForBacklinks( Title $title, $table ) {
+ public static function newForBacklinks( Title $title, $table, $params = [] ) {
return new self(
$title,
[
'recursive' => true
] + Job::newRootJobParams( // "overall" refresh links job info
"htmlCacheUpdate:{$table}:{$title->getPrefixedText()}"
- )
+ ) + $params
);
}
// Job to purge all (or a range of) backlink pages for a page
if ( !empty( $this->params['recursive'] ) ) {
+ // Carry over information for de-duplication
+ $extraParams = $this->getRootJobParams();
+ // Carry over cause information for logging
+ $extraParams['causeAction'] = $this->params['causeAction'];
+ $extraParams['causeAgent'] = $this->params['causeAgent'];
// Convert this into no more than $wgUpdateRowsPerJob HTMLCacheUpdateJob per-title
// jobs and possibly a recursive HTMLCacheUpdateJob job for the rest of the backlinks
$jobs = BacklinkJobUtils::partitionBacklinkJob(
$wgUpdateRowsPerJob,
$wgUpdateRowsPerQuery, // jobs-per-title
// Carry over information for de-duplication
- [ 'params' => $this->getRootJobParams() ]
+ [ 'params' => $extraParams ]
);
JobQueueGroup::singleton()->push( $jobs );
// Job to purge pages for a set of titles
Hooks::run( 'ArticleUndelete',
[ &$this->title, $created, $comment, $oldPageId, $restoredPages ] );
if ( $this->title->getNamespace() == NS_FILE ) {
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->title, 'imagelinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $this->title, 'imagelinks', 'file-restore' )
+ );
}
}
if ( $this->mFile->exists() ) {
wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" );
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $this->mTitle, 'imagelinks', 'file-purge' )
+ );
} else {
wfDebug( 'ImagePage::doPurge no image for '
. $this->mFile->getName() . "; limiting purge to cache only\n" );
MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );
// Invalidate caches of articles which include this page
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $title, 'templatelinks', 'page-create' )
+ );
if ( $title->getNamespace() == NS_CATEGORY ) {
// Load the Category object, which will schedule a job to create
// Images
if ( $title->getNamespace() == NS_FILE ) {
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $title, 'imagelinks', 'page-delete' )
+ );
}
// User talk pages
*/
public static function onArticleEdit( Title $title, Revision $revision = null ) {
// Invalidate caches of articles which include this page
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $title, 'templatelinks', 'page-edit' )
+ );
// Invalidate the caches of all pages which redirect here
- DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'redirect' ) );
+ DeferredUpdates::addUpdate(
+ new HTMLCacheUpdate( $title, 'redirect', 'page-edit' )
+ );
MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );