Merge "Add action/user tracking to html cache purge jobs"
This commit is contained in:
commit
b5370206ff
9 changed files with 54 additions and 17 deletions
|
|
@ -4622,9 +4622,11 @@ class Title implements LinkTarget {
|
|||
* 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' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
*
|
||||
* @ingroup Cache
|
||||
*/
|
||||
class HTMLCacheUpdate implements DeferrableUpdate {
|
||||
class HTMLCacheUpdate extends DataUpdate {
|
||||
/** @var Title */
|
||||
public $mTitle;
|
||||
|
||||
|
|
@ -36,14 +36,24 @@ class HTMLCacheUpdate implements DeferrableUpdate {
|
|||
/**
|
||||
* @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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1055,7 +1055,9 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
|
|||
$inv = [ $inv ];
|
||||
}
|
||||
foreach ( $inv as $table ) {
|
||||
DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) );
|
||||
DeferredUpdates::addUpdate(
|
||||
new HTMLCacheUpdate( $this->mTitle, $table, 'page-props' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1445,7 +1445,9 @@ abstract class File implements IDBAccessObject {
|
|||
// 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' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1740,7 +1740,9 @@ class LocalFile extends File {
|
|||
}
|
||||
|
||||
# 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,14 +47,16 @@ class HTMLCacheUpdateJob extends Job {
|
|||
// 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,
|
||||
[
|
||||
|
|
@ -62,7 +64,7 @@ class HTMLCacheUpdateJob extends Job {
|
|||
'recursive' => true
|
||||
] + Job::newRootJobParams( // "overall" refresh links job info
|
||||
"htmlCacheUpdate:{$table}:{$title->getPrefixedText()}"
|
||||
)
|
||||
) + $params
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +77,11 @@ class HTMLCacheUpdateJob extends Job {
|
|||
|
||||
// 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(
|
||||
|
|
@ -82,7 +89,7 @@ class HTMLCacheUpdateJob extends Job {
|
|||
$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
|
||||
|
|
|
|||
|
|
@ -764,7 +764,9 @@ class PageArchive {
|
|||
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' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,9 @@ class WikiFilePage extends WikiPage {
|
|||
|
||||
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" );
|
||||
|
|
|
|||
|
|
@ -3317,7 +3317,9 @@ class WikiPage implements Page, IDBAccessObject {
|
|||
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
|
||||
|
|
@ -3355,7 +3357,9 @@ class WikiPage implements Page, IDBAccessObject {
|
|||
|
||||
// Images
|
||||
if ( $title->getNamespace() == NS_FILE ) {
|
||||
DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
|
||||
DeferredUpdates::addUpdate(
|
||||
new HTMLCacheUpdate( $title, 'imagelinks', 'page-delete' )
|
||||
);
|
||||
}
|
||||
|
||||
// User talk pages
|
||||
|
|
@ -3378,10 +3382,14 @@ class WikiPage implements Page, IDBAccessObject {
|
|||
*/
|
||||
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 );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue